I am attempting a ridiculously simplistic approximation of a sine function using tflearn, inspired by this paper.
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)
But I keep running into a
ValueError: Cannot feed value of shape (10,) for Tensor u'InputData/X:0', which has shape '(?, 10, 10000)'
error.
Any ideas on where I am going wrong?
Thank you!
UPDATE : I was not assigning a shape to the x = np.linspace(-np.pi,np.pi,10000)
tensor:
Solved (@lejlot) by changing the line to np.linspace(-np.pi,np.pi,10000).reshape(-1, 1)
In the line input_data(shape=[10,10000])
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.