此類指定Estimator 運行的配置。
用法
tf.estimator.RunConfig(
model_dir=None, tf_random_seed=None, save_summary_steps=100,
save_checkpoints_steps=_USE_DEFAULT, save_checkpoints_secs=_USE_DEFAULT,
session_config=None, keep_checkpoint_max=5, keep_checkpoint_every_n_hours=10000,
log_step_count_steps=100, train_distribute=None, device_fn=None, protocol=None,
eval_distribute=None, experimental_distribute=None,
experimental_max_worker_delay_secs=None, session_creation_timeout_secs=7200,
checkpoint_save_graph_def=True
)參數
-
model_dir保存模型參數、圖形等的目錄。如果PathLike對象,路徑將被解析。如果None,將使用 Estimator 設置的默認值。 -
tf_random_seedTensorFlow 初始化程序的隨機種子。設置此值允許重新運行之間的一致性。 -
save_summary_steps每隔這麽多步驟保存摘要。 -
save_checkpoints_steps每隔這麽多步驟保存檢查點。不能用save_checkpoints_secs指定。 -
save_checkpoints_secs每隔這麽多秒保存檢查點。不能用save_checkpoints_steps指定。如果save_checkpoints_steps和save_checkpoints_secs均未在構造函數中設置,則默認為 600 秒。如果save_checkpoints_steps和save_checkpoints_secs都是None,則禁用檢查點。 -
session_config用於設置會話參數的 ConfigProto,或None。 -
keep_checkpoint_max要保留的最近檢查點文件的最大數量。創建新文件時,會刪除舊文件。如果None或 0,則保留所有檢查點文件。默認為 5(即保留 5 個最近的檢查點文件)。如果將保護程序傳遞給估計器,則此參數將被忽略。 -
keep_checkpoint_every_n_hours要保存的每個檢查點之間的小時數。默認值 10,000 小時有效地禁用了該函數。 -
log_step_count_steps在訓練期間記錄全局步長和損失的頻率,以全局步數為單位。還控製在訓練期間記錄全局步數(並寫入摘要)的頻率。 -
train_distributetf.distribute.Strategy的可選實例。如果指定,則 Estimator 將根據該策略指定的策略在訓練期間分發用戶的模型。首選設置experimental_distribute.train_distribute。 -
device_fn為每個接受Operation並返回設備字符串的Operation調用的可調用對象。如果None,默認為tf.train.replica_device_setter返回的設備函數,使用 round-robin 策略。 -
protocol一個可選參數,它指定啟動服務器時使用的協議。None表示默認為 grpc。 -
eval_distributetf.distribute.Strategy的可選實例。如果指定,則 Estimator 將根據該策略指定的策略在評估期間分發用戶的模型。首選設置experimental_distribute.eval_distribute。 -
experimental_distribute指定DistributionStrategy-related 配置的可選tf.contrib.distribute.DistributeConfig對象。train_distribute和eval_distribute可以作為參數傳遞給RunConfig或在experimental_distribute中設置,但不能同時設置。 -
experimental_max_worker_delay_secs一個可選整數,指定工作人員在開始之前應等待的最長時間。默認情況下,worker 是在交錯時間啟動的,每個 worker 最多延遲 60 秒。這是為了降低發散的風險,當許多工作人員同時更新隨機初始化模型的權重時,可能會發生發散的風險。熱啟動模型並進行短時間(幾分鍾或更短時間)訓練的用戶應考慮減少此默認值以縮短訓練時間。 -
session_creation_timeout_secs工作人員應使用 MonitoredTrainingSession 等待會話可用(在初始化或恢複會話時)的最長時間。默認為 7200 秒,但用戶可能希望設置較低的值以更快地檢測變量/會話(重新)初始化的問題。 -
checkpoint_save_graph_def是否將 GraphDef 和 MetaGraphDef 保存到checkpoint_dir。 GraphDef 在會話創建後保存為graph.pbtxt。 MetaGraphDefs 為每個檢查點保存為model.ckpt-*.meta。
拋出
-
ValueError如果同時設置了save_checkpoints_steps和save_checkpoints_secs。
屬性
-
checkpoint_save_graph_def -
cluster_spec -
device_fn返回device_fn。如果 device_fn 不是
None,它將覆蓋Estimator中使用的默認設備函數。否則使用默認值。 -
eval_distribute用於評估的可選tf.distribute.Strategy。 -
evaluation_master -
experimental_max_worker_delay_secs -
global_id_in_cluster訓練集群中的全局 id。訓練集群中的所有全局 id 都是從一個遞增的連續整數序列中分配的。第一個id是0。
注意:任務 id(屬性字段
task_id)正在跟蹤具有相同任務類型的所有節點中的節點索引。例如,給定集群定義如下:cluster = {'chief':['host0:2222'], 'ps':['host1:2222', 'host2:2222'], 'worker':['host3:2222', 'host4:2222', 'host5:2222']}任務類型
worker的節點可以有 id 0, 1, 2。任務類型ps的節點可以有 id, 0, 1。所以,task_id不是唯一的,但對 (task_type,task_id) 可以是唯一的確定集群中的一個節點。全局id,即該字段,是跟蹤該節點在集群中所有節點中的索引。它是唯一分配的。例如,對於上麵給出的集群規範,全局 id 被分配為:
task_type | task_id | global_id -------------------------------- chief | 0 | 0 worker | 0 | 1 worker | 1 | 2 worker | 2 | 3 ps | 0 | 4 ps | 1 | 5 -
is_chief -
keep_checkpoint_every_n_hours -
keep_checkpoint_max -
log_step_count_steps -
master -
model_dir -
num_ps_replicas -
num_worker_replicas -
protocol返回可選協議值。 -
save_checkpoints_secs -
save_checkpoints_steps -
save_summary_steps -
service返回定義的平台(在TF_CONFIG中)服務字典。 -
session_config -
session_creation_timeout_secs -
task_id -
task_type -
tf_random_seed -
train_distribute可選的tf.distribute.Strategy用於訓練。
相關用法
- Python tf.estimator.RegressionHead用法及代碼示例
- Python tf.estimator.TrainSpec用法及代碼示例
- Python tf.estimator.LogisticRegressionHead用法及代碼示例
- Python tf.estimator.MultiHead用法及代碼示例
- Python tf.estimator.PoissonRegressionHead用法及代碼示例
- Python tf.estimator.WarmStartSettings用法及代碼示例
- Python tf.estimator.experimental.stop_if_lower_hook用法及代碼示例
- Python tf.estimator.MultiLabelHead用法及代碼示例
- Python tf.estimator.experimental.stop_if_no_increase_hook用法及代碼示例
- Python tf.estimator.BaselineEstimator用法及代碼示例
- Python tf.estimator.DNNLinearCombinedEstimator用法及代碼示例
- Python tf.estimator.Estimator用法及代碼示例
- Python tf.estimator.experimental.LinearSDCA用法及代碼示例
- Python tf.estimator.experimental.RNNClassifier用法及代碼示例
- Python tf.estimator.experimental.make_early_stopping_hook用法及代碼示例
- Python tf.estimator.LinearRegressor用法及代碼示例
- Python tf.estimator.LinearEstimator用法及代碼示例
- Python tf.estimator.DNNClassifier用法及代碼示例
- Python tf.estimator.BaselineClassifier用法及代碼示例
- Python tf.estimator.experimental.stop_if_higher_hook用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.estimator.RunConfig。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
