Posts

Showing posts from February, 2018

Very very simple example of TensorFlow conv1d.

import tensorflow as tf import numpy as np X = np.zeros((10,10)) + 1 filter = np.zeros((5,),dtype=np.float32) + 1 x = tf.placeholder(tf.float32, shape=[None, 10, 1]) f = tf.placeholder(tf.float32, shape = [5, 1, 1]) conv = tf.nn.conv1d(x, f, 1,'SAME') session = tf.Session() result = session.run(conv, feed_dict={x:X.reshape((10,10,1)), f:filter.reshape((5,1,1))}) result.reshape((10,10)) result array([[ 3., 4., 5., 5., 5., 5., 5., 5., 4., 3.], [ 3., 4., 5., 5., 5., 5., 5., 5., 4., 3.], [ 3., 4., 5., 5., 5., 5., 5., 5., 4., 3.], [ 3., 4., 5., 5., 5., 5., 5., 5., 4., 3.], [ 3., 4., 5., 5., 5., 5., 5., 5., 4., 3.], [ 3., 4., 5., 5., 5., 5., 5., 5., 4., 3.], [ 3., 4., 5., 5., 5., 5., 5., 5., 4., 3.], [ 3., 4., 5., 5., 5., 5., 5., 5., 4., 3.], [ 3., 4., 5., 5., 5., 5., 5., 5., 4., 3.], [ 3., 4., 5., 5., 5., 5., 5., 5., 4., 3.