Kulothungan Senthil
Kulothungan Senthil

Reputation: 87

TypeError: Value passed to parameter 'input' has DataType int64 not in list of allowed values: float16, bfloat16, float32, float64

I am trying to run a model and predict a test data from mnist kaggle data set. But i am getting error when trying to predict.What is the reason and solution?

    model = tf.keras.Sequential([
        tf.keras.layers.Conv2D(32, (3,3), padding='same', activation=tf.nn.relu,
                               input_shape=(28, 28, 1)),
        tf.keras.layers.MaxPooling2D((2, 2), strides=2),
        tf.keras.layers.Conv2D(64, (3,3), padding='same', activation=tf.nn.relu),
        tf.keras.layers.MaxPooling2D((2, 2), strides=2),
        tf.keras.layers.Flatten(input_shape=(28, 28, 1)),
        tf.keras.layers.Dense(128, activation=tf.nn.relu),
        tf.keras.layers.Dense(10,  activation=tf.nn.softmax)
    ])

test = pd.read_csv("test.csv") 
test.head()
CHANNELS = 1
IMAGE_SIZE = 28
IMAGE_WIDTH, IMAGE_HEIGHT = IMAGE_SIZE, IMAGE_SIZE
test = test.values.reshape(-1, IMAGE_WIDTH, IMAGE_HEIGHT, CHANNELS)
predictions = model.predict_classes(test, verbose=1)

TypeError: Value passed to parameter 'input' has DataType int64 not in list of allowed values: float16, bfloat16, float32, float64

Upvotes: 1

Views: 1215

Answers (1)

Erfan Loghmani
Erfan Loghmani

Reputation: 637

As the TypeError is saying I think the test dataframe contains int values, so you have to change the type to float like this:

test = test.astype('float')
test = test.values.reshape(-1, IMAGE_WIDTH, IMAGE_HEIGHT, CHANNELS)
predictions = model.predict_classes(test, verbose=1)

Upvotes: 3

Related Questions