Approximating a sine function with tflearn
<p>I am attempting a ridiculously simplistic approximation of a sine function using tflearn, inspired by <a href="http://mourafiq.com/2016/05/15/predicting-sequences-using-rnn-in-tensorflow.html" rel="nofollow">this</a> paper. </p>

<pre><code>import tflearn 
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt


# generate cosine function
x = np.linspace(-np.pi,np.pi,10000)
y = np.sin(x)



# Network building
net = tflearn.input_data(shape=[10,10000])
net = tflearn.fully_connected(net, 1000)
net = tflearn.layers.core.activation (net, activation='relu')
net = tflearn.regression(net)


# Define model
model = tflearn.DNN(net)
# Start training (apply gradient descent algorithm)
model.fit(x, y,batch_size=10)
</code></pre>

<p>But I keep running into a </p>

<blockquote>
  <p>ValueError: Cannot feed value of shape (10,) for Tensor u'InputData/X:0', which has shape '(?, 10, 10000)'</p>
</blockquote>

<p>error. </p>

<p>Any ideas on where I am going wrong?</p>

<p>Thank you!</p>

<p><strong>UPDATE</strong>: I was not assigning a shape to the <code>x = np.linspace(-np.pi,np.pi,10000)</code> tensor:</p>

<p>Solved (@lejlot) by changing the line to <code>np.linspace(-np.pi,np.pi,10000).reshape(-1, 1)</code></p>

<p>In the line <code>input_data(shape=[10,10000])</code> the shape of each input tensor is actually [None,1] and so changing this line to net = tflearn.input_data(shape=[None,1]) solved the issue in the end.</p>

python machine-learning neural-network tensorflow