tensorflow - 如何在谷歌云平台上使用带有 tf.estimator 的 datalab 的 tensorboard 调试器
问题描述
当我通过 datalab 启动 tensorboard 时,它使用此处描述的 google 语法。本文档仅提及开始、停止和列表。但是,有一个我无法使用的调试器窗格。
本文档描述了如何将 tensorboard 调试器与 tf.estimator 一起使用,但它使用了不同的语法。
有没有办法将两者混合在一起,以便调试器可以与 datalab 一起使用?
解决方案
我认为您不能在 datalab 中运行 tfdbg。您可以使用本指南获取代码并在控制台上运行它:
我正在使用使用 model.py 和 task.py 的 datalab 笔记本。我的代码最初是根据这个文件建模的。
model.py
如上面提到的指南中所示,对代码进行此更改。from tensorflow.python import debug as tf_debug # for debugging hooks = [tf_debug.LocalCLIDebugHook()]
然后在train_and_evaluate(args)
例程中添加对调用的参数列表中的挂钩的引用EvalSpec()
。像这样:
# .. also need an EvalSpec which controls the evaluation and
# the checkpointing of the model since they happen at the same time
eval_spec = tf.estimator.EvalSpec(
input_fn = read_dataset(
args['eval_data_paths'],
batch_size = 10000, # original 10000
mode = tf.estimator.ModeKeys.EVAL),
steps=None, # evals on 100 batches
start_delay_secs = args['eval_delay_secs'], # start evaluating after N secoonds.
throttle_secs = args['min_eval_frequency'], # eval no more than every N seconds.
exporters = exporter,# how to export the model for production.
hooks = hooks) # for the debugger
然后使用您喜欢的虚拟 python 环境,执行以下操作:(我正在使用 anaconda)
用anaconda打开python 2.7环境
$ . ~/bin/setenv-anaconda2.sh
激活tensorflow python2.7 anaconda环境
$ conda activate tensorflow
获取 gcloud 环境
$ . ~/progs/datalab-notebooks/bin/setenv_google.sh
对于这个模型,设置一个 python 路径来查找模块
cd ~/progs/datalab-notebooks/tf-debug export PYTHONPATH=${PYTHONPATH}:${PWD}/taxisimple
然后训练:--train_steps=1000。似乎是最大步数。
python -m trainer.task \
--train_data_paths="${PWD}/taxi-train*" \
--eval_data_paths=${PWD}/taxi-valid.csv \
--output_dir=${PWD}/taxi_trained \
--train_steps=1000 --job-dir=./tmp
这会给你一个 tftdbg 提示。从这里您可以使用 tfdbg 探索模型。
推荐阅读
- javascript - 使用 Javascript 根据引荐 URL 将访问者重定向到不同的登录页面
- javascript - 如何使用正则表达式动态地对字符串应用替换 JAVASCRIPT?
- bash - 跨两台服务器传输文件的 Bash 脚本
- c++ - 零四元数和任何向量的特征积都不为零,这是一个错误吗?
- .net - CsvHelper - 将多个相关列读入对象列表
- mysql - MySQL - utf8 字符无法正确显示
- swift - 如何编写 swift 属性包装器?
- javascript - How to correctly display 2 decimals in Javascript?
- c++ - std::string == operator not working in code
- spring - 无法让我的 Spring Batch 运行任何其他工作