检查目标时发生错误:预期activation_final具有形状(60,),但数组形状为(4,)

时间:2020-05-13 11:23:52

标签: python machine-learning image-processing keras

# train the model
start = dt.now()
show = my_model.fit_generator(
# training data
train_generator,

# epochs
steps_per_epoch = train_generator.n // 32, #floor per batch size
epochs = 15, 

# validation data
validation_data = test_images_iter,
validation_steps = test_images_iter.n // 32,

#  print progress
verbose = 1,
callbacks = [
#early stopping in case the loss stops decreasing
k.callbacks.EarlyStopping(monitor='val_loss', patience=3),
# only save the model if the monitored quantity (val_loss or val_acc) has improved
k.callbacks.ModelCheckpoint("fruits_checkpoints.h5", monitor='val_loss', save_best_only = True),
# only needed for visualising with TensorBoard
k.callbacks.TensorBoard(log_dir = "logs/{:%d_%b_%Y_%H:%M:%S}".format(dt.now()) )

] ) 我开始这个错误idk如何解决它我是ML的新手 检查目标时出错:预期activation_final具有形状(60,)但具有形状(4,)的数组

1 个答案:

答案 0 :(得分:1)

用测试生成器替换test_images_iter 验证数据 validation_data = test_generator, validate_steps = test_generator.n // 32,