Python Keras:model.fit中的verbose(值1)显示较少的训练数据

Python Keras:model.fit中的verbose(值1)显示较少的训练数据,python,tensorflow,keras,Python,Tensorflow,Keras,我目前正在使用Keras 2.4.2和Tensorflow 2.2.0的最新版本,用包含100万行的Movielens-1M数据集实现一个简单的矩阵分解模型。但是,我注意到,在训练过程中,训练数据量减少了 from sklearn.model_selection import train_test_split import pandas as pd import numpy as np import keras dataset = pd.read_csv('ratings.dat', skip

我目前正在使用Keras 2.4.2和Tensorflow 2.2.0的最新版本,用包含100万行的Movielens-1M数据集实现一个简单的矩阵分解模型。但是,我注意到,在训练过程中,训练数据量减少了

from sklearn.model_selection import train_test_split
import pandas as pd
import numpy as np
import keras

dataset = pd.read_csv('ratings.dat', skiprows=1,sep='::',names="userId,itemId,rating,timestamp".split(","))

dataset.userId = dataset.userId.astype('category').cat.codes.values
dataset.itemId = dataset.itemId.astype('category').cat.codes.values

train, test = train_test_split(dataset, test_size=0.2)

#model architecture can be found link below

x = [train.userId, train.itemId]
y = train.rating

print(x[0].shape, x[1].shape, y.shape)
history = model.fit(x, y, epochs=25,
                verbose=1, validation_split=0.25)
单击以查看模型体系结构


如您所见,在验证拆分之后,培训数据的数量应该是600124。但是,详细进度条显示的值要小得多。这里发生了什么事?

这里一切都如预期的那样。18754不是训练数据的数量。这是完成一个历元的步骤数。整个训练数据分成若干组,每组称为一批。默认的批处理大小为32。这意味着,您的整个训练数据将是N个组,其中每个组包含32个训练数据

那么N的大小是多少

简单,步骤数N=总培训数据/批量大小

现在你可以自己计算了


顺便说一句,之所以使用这批数据,是因为内存有限,无法将整个训练数据加载到GPU内存中。您可以根据内存大小更改批处理大小。

哦,是的,这很有意义。应该已经阅读了文档tho。非常感谢,不客气。如果回答了你的问题,请接受这个答案。