Search code examples
tensorflowtflearn

TensorFlow/TFLearn Cannot Feed Value Of Shape


I'm coming from SciKit and trying to get the hang of TensorFlow.

net = tflearn.input_data(shape=[None, 54])
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net)
model = tflearn.DNN(net)
model.fit(data, labels, n_epoch=10, batch_size=1, show_metric=True)

My app then runs through a loop and has a function that takes a dataframe, converts it to a np array and tries to make a prediction on it.

def predict(predict_dataframe):
    df = predict_dataframe.values
    pred = model.predict([df])

but I get a cannot feed value of shape (1, 1, 54) for Tensor u'InputData/X:0', which has shape '(?, 54).

I understand I have to reshape it but not sure exactly how to go about it from the other examples Ive seen online.


Solution

  • It looks like you're wrapping it in an extra list. Try pred = model.predict(df).