I have the following code and I would like to plot the graph of loss
against steps_per_epoch
model = unet(pretrained=False)
model.compile(optimizer=Adam(0.005), loss="binary_crossentropy",
metrics=["accuracy"])
history = model.fit_generator(train_gen, steps_per_epoch=500, epochs=5,
callbacks=[dynamic_lr, chkp])
where lr
and chkp
are my callbacks for the model:
def lr_scheduler(epoch, lr):
if epoch <= 2:
lr = 0.002
return lr
lr = 0.001
return lr
chkp = keras.callbacks.ModelCheckpoint(
filepath="mypath/model.hdf5",
monitor="loss",
verbose=1,
save_best_only=True,
mode="min",
)
dynamic_lr = LearningRateScheduler(lr_scheduler, verbose=1)
I do not think the history
dict holds the loss
for each step in epoch, but is there any way?
you can get the values of training accuracy, training loss, validation accuracy and validation loss from the history object. See code below.
training_accuracy=history.history['accuracy']
training_loss=history.history['loss']
valid_accuracy=history.history['val_accuracy']
valid_loss=history.history['val_loss']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.