tensorflow —— tf.contrib

tf.contrib

tf.contrib.data.map_and_batch

把map和batch混在一起并行处理

dataset.apply(tf.contrib.data.map_and_batch())

tf.contrib.tpu

tf.contrib.tpu.RunConfig
tpu_config=None,  # TPUConfig(required by TPUEstimator) that specifies TPU-specific configuration.
evaluation_master=None,  #  The address of the master to use for eval. Defaults to master if not set.
master=None,  # The address of the master to use for training. Tensorflow master url.
cluster=None,  # a ClusterResolver
**kwargs  # keyword config parameters.
tf.contrib.tpu.TPUConfig

iterations_per_loop: the number of train steps;global step is increased iterations_per_loop times in one Session.run
num_shards: (Deprecated, ignored by TPUEstimator). The number of model replicas in the system. non-model-parallelism :equals the total number of TPU cores;model-parallelism:the total number of TPU cores = num_cores_per_replica * num_shards.

tf.contrib.tpu.TPUEstimator:TPU上运行模型

Estimator是tensorflow的模型级抽象层。
标准Estimators可以在CPU和GPU上运行模型。

维护可在 CPU/GPU 或 Cloud TPU 上运行的模型:最简单的方式是将模型的推理阶段(从输入到预测)定义在 model_fn 之外。确保 Estimator 设置和 model_fn 的单独实现,二者均包含此推理步骤。

在本地运行 TPUEstimator
创建标准 Estimator

调用构造函数,然后将它传递给 model_fn

my_estimator = tf.estimator.Estimator(
  model_fn=my_model_fn)
本地计算机上使用TPUEstimator

构造函数需要两个额外的参数:use_tpu = False,并将 tf.contrib.tpu.RunConfig 以 config 参数的形式传递。

my_tpu_estimator = tf.contrib.tpu.TPUEstimator(
    model_fn=my_model_fn,
    config=tf.contrib.tpu.RunConfig()
    use_tpu=False)
设置命令行标记
python mnist_tpu.py --use_tpu=false --master=''
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值