随着tensorflow的不断更新,直接按照nmt的教程搭建nmt环境会报错的。。。因此,需要一些不太好的办法来避免更多的问题出现。
tensorflow看来在ubuntu和debian中运行是没有问题的。因此,选用ubuntu作为环境系统。
由于tf-nightly越来越远了,因此,先使用tf-1.4让程序能够正常运行再考虑其他的问题吧。
python选用默认的2.7,安装easy-pip。
有了python的支持,我们同样需要使用指定版本的tf,一边支持nmt对应的版本(否则会报错,无法正常使用).
pip install tensorflow==1.4.0(这里只安装了CPU版本)

git clone https://github.com/tensorflow/nmt/
使用 git branch -a 查看所下载的nmt的所有分支。
切换到tf-1.4版本:
git checkout -b tf-1.4 origin/tf-1.4
Branch tf-1.4 set up to track remote branch tf-1.4 from origin.
Switched to a new branch ‘tf-1.4’
至此,我们可以按照nmt教程去做了:
mkdir /tmp/nmt_model
python -m nmt.nmt \
–src=vi –tgt=en \
–vocab_prefix=/tmp/nmt_data/vocab \
–train_prefix=/tmp/nmt_data/train \
–dev_prefix=/tmp/nmt_data/tst2012 \
–test_prefix=/tmp/nmt_data/tst2013 \
–out_dir=/tmp/nmt_model \
–num_train_steps=12000 \
–steps_per_stats=100 \
–num_layers=2 \
–num_units=128 \
–dropout=0.2 \
–metrics=bleu

可以看到,上面的参数把越南语翻译为英语了.反向翻译,则只需要调换,即:
–src=en –tgt=vi
由于这个过程比较慢,我们可以用tf的cgi接口查看状态:
tensorboard –port 22222 –logdir /tmp/nmt_model/
这样,就可以访问本地22222端口来看具体训练状态了.
我在三代笔记本i5训练了小规模语料库,不到10个小时。

接下来,可以翻译一些文本了:
cat > /tmp/my_infer_file.vi
# (copy and paste some sentences from /tmp/nmt_data/tst2013.vi)

python -m nmt.nmt \
–out_dir=/tmp/nmt_model \
–inference_input_file=/tmp/my_infer_file.vi \
–inference_output_file=/tmp/nmt_model/output_infer

cat /tmp/nmt_model/output_infer # To view the inference as output
参考网文:
nmt官方教程

Python查看库版本命令

git切换分支

git删除本地分支

tf安装指定版本

tensorflow nmt基本配置(tf-1.4)的更多相关文章

  1. Tensorflow开发环境配置及其基本概念

    Tensorflow开发环境配置及其基本概念 1.1. 安装Tensorflow开发环境 1.1.1. 安装pycharm 1.1.2. 安装pythe3.6 1.1.3. 安装Tensorflow ...

  2. TensorFlow NMT的数据处理过程

    在tensorflow/nmt项目中,训练数据和推断数据的输入使用了新的Dataset API,应该是tensorflow 1.2之后引入的API,方便数据的操作.如果你还在使用老的Queue和Coo ...

  3. TensorFlow NMT的词嵌入(Word Embeddings)

    本文转载自:http://blog.stupidme.me/2018/08/05/tensorflow-nmt-word-embeddings/,本站转载出于传递更多信息之目的,版权归原作者或者来源机 ...

  4. Tensorflow使用环境配置

    windows中不能直接使用Tensorflow,所以得费点劲.(2016.11.29更新,TensorFlow 0.12 中已加入初步的 Windows 原生支持) 先是直接使用了<Deep ...

  5. Ubuntu 14.04 关于 TensorFlow 环境的配置

    Ubuntu 14.04 关于 TensorFlow 环境的配置   本教程截图于 TensorFlow 官方文档中文版  https://github.com/jikexueyuanwiki/ten ...

  6. Tensorflow滑动平均模型tf.train.ExponentialMovingAverage解析

    觉得有用的话,欢迎一起讨论相互学习~Follow Me 移动平均法相关知识 移动平均法又称滑动平均法.滑动平均模型法(Moving average,MA) 什么是移动平均法 移动平均法是用一组最近的实 ...

  7. import tensorflow 报错: tf.estimator package not installed.

    import tensorflow 报错: tf.estimator package not installed. 解决方案1: 安装 pip install tensorflow-estimator ...

  8. tensorflow笔记6:tf.nn.dynamic_rnn 和 bidirectional_dynamic_rnn:的输出,output和state,以及如何作为decoder 的输入

    一.tf.nn.dynamic_rnn :函数使用和输出 官网:https://www.tensorflow.org/api_docs/python/tf/nn/dynamic_rnn 使用说明: A ...

  9. 【深度学习】在linux和windows下anaconda+pycharm+tensorflow+cuda的配置

    在linux和windows下anaconda+pycharm+tensorflow+cuda的配置 在linux和windows下anaconda+pycharm+tensorflow+cuda的配 ...

随机推荐

  1. 【luogu P3376 网络最大流】 模板

    题目链接:https://www.luogu.org/problemnew/show/P3376 #include <iostream> #include <cstdio> # ...

  2. onInterceptTouchEvent和onTouchEvent调用关系详解 ...

    http://blog.csdn.net/lvxiangan/article/details/9309927 老实说,这两个小东东实在是太麻烦了,很不好懂,我自己那api文档都头晕,在网上找到很多资料 ...

  3. Android学习笔记_27_多媒体之视频刻录

    一.配置文件: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android= ...

  4. An error occurred during the installation of assembly 'Microsoft.VC90.ATL or 'Microsoft.VC80.ATL'

    An error occurred during the installation of assembly 'Microsoft.VC90.ATL or 'Microsoft.VC80.ATL' 下载 ...

  5. TDD: 解除依赖

    1  A类依赖B 类,可以把B类提取成IB接口,解除AB 之间的依赖关系. 通过创建实现了IB接口的BStub 装代码,可以模拟B类进行测试. 这是针对接口编程的典型.适合构造代价大,变化多的情况.应 ...

  6. sql server 中数据库数据导入到另一个库中

    这篇说了sql语句对于备份的数据库进行还原 ,如果数据量大了还是什么问题,发现我的数据丢失了一些,头疼 sql server 备份还原 下面使用的的数据导入来解决这个问题,因为数据量比较大,导出来的脚 ...

  7. Python基础—02-数据类型

    数据类型 存储单位 最小单位是bit,表示二进制的0或1,一般写作b 最小的存储单位是字节,用byte表示,1B = 8b 1024B = 1KB 1024KB = 1MB 1024MB = 1GB ...

  8. c# 分析SQL语句中的表操作

    最近写了很多方向的总结和demo.基本包含了工作中的很多方面,毕竟c#已经高度封装并且提供了很多类库.前面已经总结了博文.最近2天突然感觉前面的SQL分析阻组件的确麻烦,也注意看了下.为了方便大家学习 ...

  9. Linux 下文件压缩与解压命令详解

    tar 命令 -c 建立压缩档案 -x 解压 -t 查看内容 -r 向压缩归档文件末尾追加文件 -u 更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中 ...

  10. MB/s与Mbit/s的区别

    数据传输率的单位一般采用MB/s或Mbit/s,尤其在内部数据传输率上官方数据中更多的采用Mbit/s为单位.此处有必要讲解一下两个单位二者之间的差异: MB/s的含义是兆字节每秒,Mbit/s的含义 ...