We will first look at one-dimensional data. We need to generate a random array of data for this task using the following steps:
- 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()
- 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])
- 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: