Marc
Marc

Reputation: 165

Tensorflow/TFLearn - ValueError: Cannot feed value of shape (64,) for Tensor 'target/Y:0', which has shape '(?, 1)'

I've been trying to perform a deep neural network to predict a value using tflearn and my own dataset.

My Neural Network is based in the example of the Titanic but with the difference that I changed the Output layer from 2 to 1 and the activation of 'softmax' to 'lineal':

from tflearn.data_utils import load_csv

data, labels = load_csv('data.csv')

# Build neural network
net = tflearn.input_data(shape=[None, 5])
net = tflearn.fully_connected(net, 5,  activation='sigmoid')
net = tflearn.fully_connected(net, 3,  activation='sigmoid')
net = tflearn.fully_connected(net, 1, activation='linear')
net = tflearn.regression(net, optimizer='sgd', loss='mean_square',  learning_rate=0.1, name='target')

# Define model
model = tflearn.DNN(net)
# Start training (apply gradient descent algorithm)
model.fit(data, labels,show_metric=True)

I get the following error:

ValueError: Cannot feed value of shape (64,) for Tensor 'target/Y:0', which has shape '(?, 1)'

I've done a search for my problem in stackoverflow but none of the answers works for me.

I use Python 3.6 and TFlearn 0.3.2

Upvotes: 1

Views: 3189

Answers (1)

Ishant Mrinal
Ishant Mrinal

Reputation: 4918

you can just reshape the labels

data, labels = load_csv('data.csv')
labels = np.reshape(labels, (-1, 1))

Upvotes: 2

Related Questions