tensorflow - 如何运行 tensorflow seq2seq 演示

标签 tensorflow

我安装了 tensorflow 并成功通过了 MNIST 演示。现在,我正在尝试运行 seq2seq demo ,但这对我不起作用。

我克隆了他们 github 存储库的一个版本,并尝试从存储库根目录运行一些列出的命令。

$ bazel run -c opt ./tensorflow/models/rnn/translate/translate.py 
    ERROR: Bad target pattern './tensorflow/models/rnn/translate/translate.py': package names may contain only A-Z, a-z, 0-9, '/', '-' and '_'.
    INFO: Elapsed time: 0.115s
    ERROR: Build failed. Not running target.

这并不奇怪,因为让 bazel 执行 python 脚本并没有什么意义。

在教程的后面,

$ bazel run -c opt //tensorflow/models/rnn/translate:translate \
  --data_dir ./data_dir --train_dir ./checkpoints_directory \
  --en_vocab_size=40000 --fr_vocab_size=40000

Unrecognized option: --data_dir

如果我从上面的调用中删除参数,它将在执行 translate 之前尝试(并失败)构建整个 tensorflow 项目。 .这不是我想要的,因为我已经使用 pip 成功安装了 tensorflow 。

我尝试运行的最后一件事,

$ python ./tensorflow/models/rnn/translate/translate.py 
Traceback (most recent call last):
  File "./tensorflow/models/rnn/translate/translate.py", line 28, in <module>
    from tensorflow.models.rnn.translate import data_utils
ImportError: No module named translate

环境信息:OS X 10.11.1、Python 2.7.10 (anaconda)

最佳答案

有两种方法可以运行脚本:

1) 用 -- 作为 bazel run 的一部分分隔脚本参数

bazel run -c opt //tensorflow/models/rnn/translate:translate -- \
--data_dir ./data_dir --train_dir ./checkpoints_directory \
--en_vocab_size=40000 --fr_vocab_size=40000

2) 构建然后从 ./bazel-bin/ 运行:
bazel build -c opt //tensorflow/models/rnn/translate:translate

./bazel-bin/tensorflow/models/rnn/translate/translate \
--data_dir ./data_dir --train_dir ./checkpoints_directory \
--en_vocab_size=40000 --fr_vocab_size=40000

关于tensorflow - 如何运行 tensorflow seq2seq 演示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33663980/

相关文章:

Tensorflow:将数据提供给图形

Tensorflow 对象检测 API : how to use imgaug for augmentation?

python - 如何在Tensorflow中计算矩阵乘积的对角线?

numpy - Tensorflow:如何将 numpy 预训练的权重分配给图形的子部分?

performance - Tensorflow - 添加 Dropout 层显着增加推理时间

python - 使用 Keras (PIL) 和 TensorFlow 调整图像大小不一致?

python - 在 Keras 中训练 GAN 时,是否需要多次通过来优化生成器和鉴别器?

python - 在 TensorFlow 中创建图形时确定张量形状

python - Keras 比 TensorFlow 慢得不合理

speech-recognition - 使用 TensorFlow 语音到文本