How to do it...

We will first look at one-dimensional data. We need to generate a random array of data for this task using the following steps:

  1. We'll start by loading the libraries we need and starting a graph session, as follows:
import tensorflow as tf 
import numpy as np 
sess = tf.Session() 
  1. Now we can initialize our data (a NumPy array of length 25) and create the placeholder that we will feed it through with the following code:
data_size = 25 
data_1d = np.random.normal(size=data_size) 
x_input_1d = tf.placeholder(dtype=tf.float32, shape=[data_size])
  1. Next, we will define a function that will make a convolutional layer. Then we will declare a random filter and create the convolutional layer, as follows:
Note that many of TensorFlow's ...

Get TensorFlow Machine Learning Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.