當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python tf.train.Checkpoint.read用法及代碼示例

用法

read(
    save_path, options=None
)

參數

返回

  • 加載狀態對象,可用於對檢查點恢複的狀態進行斷言。有關詳細信息,請參閱restore

讀取用 write 編寫的訓練檢查點。

讀取此 Checkpoint 及其依賴的任何對象。

此方法與restore() 類似,但不期望檢查點中的save_counter 變量。它隻恢複檢查點已經依賴的對象。

該方法主要供使用write() 而不是save() 並具有自己的機製來編號和跟蹤檢查點的更高級別的檢查點管理實用程序使用。

示例用法:

# Create a checkpoint with write()
ckpt = tf.train.Checkpoint(v=tf.Variable(1.))
path = ckpt.write('/tmp/my_checkpoint')

# Later, load the checkpoint with read()
# With restore() assert_consumed() would have failed.
checkpoint.read(path).assert_consumed()

# You can also pass options to read(). For example this
# runs the IO ops on the localhost:
options = tf.train.CheckpointOptions(
    experimental_io_device="/job:localhost")
checkpoint.read(path, options=options)

相關用法


注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.train.Checkpoint.read。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。