我正在尝试运行模型并根据mnist kaggle数据集预测测试数据。但是尝试进行预测时出现错误。原因和解决方法是什么?
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:传递给参数'input'的值的DataType int64不在 允许值的列表:float16,bfloat16,float32,float64
答案 0 :(得分:1)
正如TypeError所说,我认为step = 4
[l[i::step] for i in range(len(l)//(step-1))]
# [[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]
数据帧包含test
值,因此您必须像这样将类型更改为float:
int