W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
LambdaCallback
繼承自: Callback
定義在:tensorflow/python/keras/callbacks.py。
用于動(dòng)態(tài)創(chuàng)建簡(jiǎn)單的自定義回調(diào)的回調(diào)。
此回調(diào)是使用將在適當(dāng)時(shí)間調(diào)用的匿名函數(shù)構(gòu)造的。請(qǐng)注意,回調(diào)需要位置參數(shù),如下所示:
參數(shù):
示例:
# Print the batch number at the beginning of every batch.
batch_print_callback = LambdaCallback(
on_batch_begin=lambda batch,logs: print(batch))
# Stream the epoch loss to a file in JSON format. The file content
# is not well-formed JSON but rather has a JSON object per line.
import json
json_log = open('loss_log.json', mode='wt', buffering=1)
json_logging_callback = LambdaCallback(
on_epoch_end=lambda epoch, logs: json_log.write(
json.dumps({'epoch': epoch, 'loss': logs['loss']}) + '\n'),
on_train_end=lambda logs: json_log.close()
)
# Terminate some processes after having finished model training.
processes = ...
cleanup_callback = LambdaCallback(
on_train_end=lambda logs: [
p.terminate() for p in processes if p.is_alive()])
model.fit(...,
callbacks=[batch_print_callback,
json_logging_callback,
cleanup_callback])
__init__
__init__(
on_epoch_begin=None,
on_epoch_end=None,
on_batch_begin=None,
on_batch_end=None,
on_train_begin=None,
on_train_end=None,
**kwargs
)
初始化自我。
on_batch_begin
on_batch_begin(
batch,
logs=None
)
on_batch_end
on_batch_end(
batch,
logs=None
)
on_epoch_begin
on_epoch_begin(
epoch,
logs=None
)
on_epoch_end
on_epoch_end(
epoch,
logs=None
)
on_train_batch_begin
on_train_batch_begin(
batch,
logs=None
)
on_train_batch_end
on_train_batch_end(
batch,
logs=None
)
on_train_begin
on_train_begin(logs=None)
on_train_end
on_train_end(logs=None)
set_model
set_model(model)
set_params
set_params(params)
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: