Python 模型拟合训练数
这是我的拟合方法Python 模型拟合训练数,python,tensorflow,keras,deep-learning,Python,Tensorflow,Keras,Deep Learning,这是我的拟合方法 history = model.fit( x_train, y_train, batch_size=64, epochs=2, # We pass some validation for # monitoring validation loss and metrics # at the end of each epoch validation_data=(x_val, y_val), ) Fit model
history = model.fit(
x_train,
y_train,
batch_size=64,
epochs=2,
# We pass some validation for
# monitoring validation loss and metrics
# at the end of each epoch
validation_data=(x_val, y_val),
)
Fit model on training data
Epoch 1/2
782/782 [==============================] - 1s 1ms/step - loss: 0.5879 - sparse_categorical_accuracy: 0.8403 - val_loss: 0.1954 - val_sparse_categorical_accuracy: 0.9453
Epoch 2/2
782/782 [==============================] - 1s 824us/step - loss: 0.1732 - sparse_categorical_accuracy: 0.9496 - val_loss: 0.1287 - val_sparse_categorical_accuracy: 0.9618
这是什么?你可以看到在第2/2纪元之后有782/782。我想知道数字是多少(782)782是每个时代处理的批次总数。当您的模型训练时,您可以看到批处理计数器从0增长到782。
显然,您的数据集大小约为50000。当您将50K除以64(批量大小)时,您得到的值刚好低于782。这意味着最后一批的大小将小于64。但您可以看到,我在fit方法中设置了batch_size=64。那么这意味着什么呢?指定批大小(64个数据点)并
fit()
将数据集拆分为所需的批数(782)781*64+1*16=50000
tf.keras.fit()的更多信息