I designed an artificial neural networks model following the tutorial in here: https://www.tensorflow.org/tutorials/keras/regression
Afterwards, I saved the model using model.save(), and I tried loading it into a different notebook because that's how i expect people use trained models (importing them). Also I'm trying to design a code that allows me to predict any number of values i want (6, 7, 8, 2, whatever), so I'm trying to get this prediction data into an array to feed it to model_predict.
I was trying to make a simple prediction, but I'm failing everytime. How do I use model.predict() in situations like this?
Here's the code I was trying to use:
import pandas as pd
from sklearn import datasets
import tensorflow as tf
import itertools
model = tf.keras.models.load_model('MPG_Model.model')
prediction_input = {
'Cylinders' : [4],
'Displacement' : [140.0],
'Horsepower' : [86.0],
'Weight' : [2790.0],
'Acceleration' : [15.6],
'Model Year' : [82],
'Origin' : [1],
}
dataset = tf.convert_to_tensor(prediction_input)
predictions = model.predict(dataset).flatten()
It returns the following error message:
ValueError: Attempt to convert a value ({'Cylinders': [4], 'Displacement': [140.0], 'Horsepower': [86.0], 'Weight': [2790.0], 'Acceleration': [15.6], 'Model Year': [82], 'Origin': [1]}) with an unsupported type (<class 'dict'>) to a Tensor.
What should I do?