self.iterations 在 Keras 的优化器类中指的是什么



我一直在尝试理解Keras'Optimizer类,并意识到有一个我不太理解的变量——self.iterations。这是否指:

  1. 已执行更新的单个样本的数量
  2. 已执行更新的单个批次的数量?(我相信(
  3. 已执行更新的总时期数(即通过训练集的完整时间(

是2。

整个keras函数每批迭代一次。

一种测试方法是获得一个小数组的数据并训练一个历元:

#get 3 batches of size 32 from the data
small_X = X_train[:3*32]
small_Y = Y_train[:3*32]
#print the initial value of iterations
print(keras.backend.eval(model.optimizer.iterations))
#train for 1 epoch with batch size 32
model.fit(small_X, small_Y, epochs=1, batch_size=32, verbose=0)
#see the new value of iterations
print(keras.backend.eval(model.optimizer.iterations))

相关内容

最新更新