【发布时间】:2016-10-20 03:14:18
【问题描述】:
我尝试在小批量梯度下降中打印学习率。但是 Ir 在许多时期保持不变(始终为 0.10000000149)。但它应该改变每一个小批量。代码如下:
# set the decay as 1e-1 to see the Ir change between epochs.
sgd = SGD(lr=0.1, decay=1e-1, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy',
optimizer=sgd,
metrics=['accuracy'])
class LossHistory(Callback):
def on_epoch_begin(self, batch, logs={}):
lr=self.model.optimizer.lr.get_value()
print('Ir:', lr)
history=LossHistory()
model.fit(X_train, Y_train,
batch_size= batch_size,
nb_epoch= nb_epoch,
callbacks= [history])
【问题讨论】:
标签: python deep-learning keras