title: Tensorflow reshaping error for 1d convolutional neural net
body: <p>I am building a 1d convolutional neural net for my own data (spectra) and am having an issue with tf.reshape. First I load in the data with pandas, and convert these to numpy arrays, composed of 708 training example spectra, each of length 2151,</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  data = pd.read_csv('test.csv',header=None)
  yTrue = data.ix[:,0].as_matrix()
  data = data - data.mean()
  data = data.ix[:,1:].as_matrix()
  </code></pre>
  
  <p>where I subtract the mean value in each column. So data is of dimensions 708 x 2151 here. I then create a network that starts with,</p>
  
  <pre><code>sess = tf.InteractiveSession()
  ## define inputs
  x_ = tf.placeholder(tf.float32, shape=[None, 2151])
  x_ = tf.reshape(x_, [-1,1,2151,1])
  y_ = tf.placeholder(tf.float32, shape=[None])
  </code></pre>
  
  <p>which are inputs for my 1d convolutional neural net (with kernels with a width of 10, and 32 feature maps),</p>
  
  <pre><code>W_conv1 = weight_variable([1, 10, 1, 32])
  b_conv1 = bias_variable([32])
  h_conv1 = tf.nn.relu(conv2d(x_, W_conv1) + b_conv1)
  h_pool1 = max_pool_2x2(h_conv1)
  </code></pre>
  
  <p>I then build the rest of the network and then try to run ADAM on it,</p>
  
  <pre><code>cost_function = tf.reduce_mean(tf.pow(y_out - y_, 2))/(2 * samples_number) #L2 loss
  train_step = tf.train.AdamOptimizer(1e-4).minimize(cost_function)
  correct_prediction = tf.equal(tf.argmax(y_out,1), tf.argmax(y_,1))
  sess.run(tf.initialize_all_variables())
  for i in range(20000):
      print(i)
      sess.run(train_step, feed_dict={x_: data, y_: yTrue})
  </code></pre>
  
  <p>However I get the following error:</p>
  
  <pre><code>ValueError: Cannot feed value of shape (708, 2151) for Tensor u'Reshape_26:0', 
  which has shape '(?, 1, 2151, 1)'
  </code></pre>
  
  <p>I have looked at these answers: <a href="https://stackoverflow.com/questions/37433321/tensorflow-tflearn-valueerror-cannot-feed-value-of-shape-64-for-tensor-uta">TensorFlow/TFLearn: ValueError: Cannot feed value of shape (64,) for Tensor u&#39;target/Y:0&#39;, which has shape &#39;(?, 10)&#39;</a>; <a href="https://stackoverflow.com/questions/33974231/tensorflow-error-using-my-own-data">Tensorflow error using my own data</a> which suggest that I need to be doing some reshaping before I pass my data to the network. However, I am not sure what this should be? Particularly since the following works on the first row of the data,</p>
  
  <pre><code>t = tf.constant(data[0])
  tf.reshape(t,[1,1,2151,1])
  </code></pre>
  
  <p>Does anyone have any ideas here?</p>
  
  <p>Best,</p>
  
  <p>Ben</p>