【发布时间】:2019-01-30 10:54:28
【问题描述】:
我正在尝试使用手动管理的图像数据集和相关标签来训练一个简单的神经网络。
我创建了一个 numpy 来创建名为 facey_label 的标签。
我已经使用 matplotlib 的 imread 函数将 811 个图像中的每一个转换为一个形状为 (255, 255, 3) 的数组,然后计划使用 np.array 函数创建一个形状为 (811, 255, 255, 3)
model = keras.Sequential([
keras.layers.Flatten(input_shape=(811, 255, 255, 3)),
keras.layers.Dense(128, activation=tf.nn.relu),
keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(img_array, facey_label, epochs=5)
但是,我收到错误:
ValueError: Error when checking input: expected flatten_1_input to have 5 dimensions, but got array with shape (811, 250, 250, 3)
我做错了什么?
【问题讨论】:
标签: image machine-learning keras