= { "learning_rate": 0.001, } # ========== 构建Estimator ========== # config = tf.estimator.RunConfig...通过tf.estimator.RunConfig()配置构建Estimator对象;2. 初始化estimator(model_dir如果非空则自动热启动);3....tf.ConfigProto中配置train_distribute就可以了: strategy = tf.distribute.experimental.ParameterServerStrategy() config = tf.estimator.RunConfig
▌主要特点及改进 可以将 tf.contrib.distribute.MirroredStrategy() 传递给 tf.estimator.RunConfig() ,能够在一台有多个 GPU 的机器上运行评估器
loss='sparse_categorical_crossentropy', metrics=['accuracy']) # 对抗训练 adv_config = tf.estimator.RunConfig
def build_estimator(model_dir): sparse_feature, dense_feature= build_features() run_config = tf.estimator.RunConfig
TensorFlow原始代码: config = tf.estimator.RunConfig( model_dir = FLAGS.model_dir, save_checkpoints_steps
当我们使用tf.contrib.learn.RunConfig的时候,另外还有一个tf.estimator.RunConfig的版本。
最后,tensorflow官方终于也在1.11版本中支持了allreduce的分布式训练策略CollectiveAllReduceStrategy,其跟estimator配合使用非常方便,只需要构造tf.estimator.RunConfig
256, 64, 32] dropout = 0.3 my_dnn_optimizer = tf.keras.optimizers.Nadam(learning_rate=0.001) config = tf.estimator.RunConfig
tf.estimator.LinearRegressor( feature_columns=feature_columns, optimizer=my_optimizer, config=tf.estimator.RunConfig
828行定义的run_config改为: # Add MirroredStrategy strategy = tf.distribute.MirroredStrategy() run_config = tf.estimator.RunConfig
为此,我们必须使用tf.estimator.RunConfig API为预估程序创建一个配置。
ParameterServerStrategy 的使用样例如下: strategy = tf.distribute.experimental.ParameterServerStrategy() run_config = tf.estimator.RunConfig
也可以将 tf.distribution.Strategy 的派生类传递给 tf.estimator.RunConfig 来指定 tf.estimator.Estimator 应该如何分配计算,具体可以参照
要将tf.estimator.Estimator类转换为使用tf.contrib.tpu.TPUEstimator,您将需要执行以下步骤: 将tf.estimator.RunConfig更改为tf.contrib.tpu.RunConfig
领取专属 10元无门槛券
手把手带您无忧上云