Reputation: 187
I am working on a project in TensorFlow that performs operations on already-trained machine learning models. Following the tutorial TFLearn Quickstart, I built a deep neural network that predicts survival from the Titanic Dataset. I would like to use the TFLearn model in the same way that I would use a TensorFlow model.
The TFLearn docs homepage says
Full transparency over Tensorflow. All functions are built over tensors and can be used independently of TFLearn
This makes me think that I would be able to pass tensors as inputs, etc. to the the TFLearn model.
# Build neural network
net = tflearn.input_data(shape=[None, 6])
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net)
# Define model
model = tflearn.DNN(net)
# Start training (apply gradient descent algorithm)
model.fit(data, labels, n_epoch = 10, batch_size = 16, show_metric = False)
test = preprocess([[3, 'Jack Dawson', 'male', 19, 0, 0, 'N/A', 5.0000]], to_ignore)
# Make into a tensor
testTF = [tf.constant(i) for i in test]
# Pass the tensor into the predictor
print(model.predict([testTF]))
At present, when I pass a tensor into the model I am greeted with ValueError: setting an array element with a sequence.
Specifically, how can you pass tensors into a TFLearn model? Generally, what limits are placed on how I can use tensors on a TFLearn model?
Upvotes: 0
Views: 582
Reputation: 1064
I don't know if you're still looking for an answer to your problem, but I think the issue is on your very last line:
print(model.predict([testTF]))
Try this instead:
print(model.predict(testTF))
I think that you nested a list inside another list. This isn't a TFlearn issue per se. Hope that helps.
Upvotes: 0