我正在尝试使用 fit(( 方法和 tf.keras 训练我的模型,因为输入数据来自 hdf5 文件,所以我将参数 shuffle='batch' 传递给 fit(( 方法。但是在第一个纪元结束后,会出现以下错误:
TypeError: TypeError while preparing batch. If using HDF5 input data, pass shuffle="batch".
这是我的fit((方法:
model.fit(
x=features_train,
y=topics_train,
batch_size=16384,
epochs=35,
callbacks=create_callbacks(),
validation_data=(features_val, topics_val),
shuffle='batch'
)
变量features_train
和features_val
取自 hdf5 文件。
通过将features_val
转换为numpy数组来解决它。
features_val_arr = np.array(features_val)
model.fit(
x=features_train,
y=topics_train,
batch_size=16384,
epochs=35,
callbacks=create_callbacks(),
validation_data=(features_val_arr, topics_val),
shuffle='batch'
)