我在训练时尝试更改批量大小,所以我在循环中运行 fit 方法并更改批量大小,但是我们已经image_dataset_from_directory()在我可以在 fit 方法中控制批量大小,并且不受image_dataset_from_directory()
我的代码的影响
train_ds = tf.keras.preprocessing.image_dataset_from_directory(
data_dir,
validation_split=0.2,
subset="training",
seed=123,
image_size=(img_height, img_width),
batch_size=batch_size)
model.fit(
train_ds,
validation_data=val_ds,
epochs=epoch,
batch_size=batch_size,
steps_per_epoch=10,
callbacks=call
)
代码取自tensorflow教程