• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

lingvo: Lingvo 是一个用于在 Tensorflow 中构建神经网络的框架,特别是序列模型 ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

lingvo

开源软件地址:

https://gitee.com/mirrors/lingvo

开源软件介绍:

Lingvo

PyPIPython

Documentation

License

What is it?

Lingvo is a framework for building neural networks in Tensorflow, particularlysequence models.

A list of publications using Lingvo can be found here.

Table of Contents

Releases

PyPI VersionCommit
0.11.06fae10077756f54beacd5c454959f20b33fd65e2
0.10.0075fd1d88fa6f92681f58a2383264337d0e737ee
0.9.1c1124c5aa7af13d2dd2b6d43293c8ca6d022b008
0.9.0f826e99803d1b51dccbbbed1ef857ba48a2bbefe
Older releases

PyPI VersionCommit
0.8.293e123c6788e934e6b7b1fd85770371becf1e92e
0.7.2b05642fe386ee79e0d88aa083565c9a93428519e

Details for older releases are unavailable.

Major breaking changes

NOTE: this is not a comprehensive list. Lingvo releases do not offer anyguarantees regarding backwards compatibility.

HEAD

Nothing here.

0.11.0

  • General
    • Tensorflow 2.7 is now the required version.
    • Python 3.6 support has been removed.

0.10.0

  • General
    • Tensorflow 2.6 is now the required version.
    • The theta_fn arg to CreateVariable() has been removed.

0.9.1

  • General
    • Python 3.9 is now supported.
    • ops.beam_search_step now takes and returns an additional argbeam_done.
    • The namedtuple beam_search_helper.BeamSearchDecodeOutput now removes thefield done_hyps.

0.9.0

  • General
    • Tensorflow 2.5 is now the required version.
    • Python 3.5 support has been removed.
    • py_utils.AddGlobalVN and py_utils.AddPerStepVN have been combined intopy_utils.AddVN.
    • BaseSchedule().Value() no longer takes a step arg.
    • Classes deriving from BaseSchedule should implement Value() not FProp().
    • theta.global_step has been removed in favor of py_utils.GetGlobalStep().
    • py_utils.GenerateStepSeedPair() no longer takes a global_step arg.
    • PostTrainingStepUpdate() no longer takes a global_step arg.
    • The fatal_errors argument to custom input ops now takes error messagesubstrings rather than integer error codes.
Older releases

0.8.2

  • General
    • NestedMap Flatten/Pack/Transform/Filter etc now expand descendent dictsas well.
    • Subclasses of BaseLayer extending from abc.ABCMeta should now extendbase_layer.ABCLayerMeta instead.
    • Trying to call self.CreateChild outside of __init__ now raises anerror.
    • base_layer.initializer has been removed. Subclasses no longer need todecorate their __init__ function.
    • Trying to call self.CreateVariable outside of __init__ or_CreateLayerVariables now raises an error.
    • It is no longer possible to access self.vars or self.theta inside of__init__. Refactor by moving the variable creation and access to_CreateLayerVariables. The variable scope is set automaticallyaccording to the layer name in _CreateLayerVariables.

Details for older releases are unavailable.

Quick start

Installation

There are two ways to set up Lingvo: installing a fixed version through pip, orcloning the repository and building it with bazel. Docker configurations areprovided for each case.

If you would just like to use the framework as-is, it is easiest to just installit through pip. This makes it possible to develop and train custom models usinga frozen version of the Lingvo framework. However, it is difficult to modify theframework code or implement new custom ops.

If you would like to develop the framework further and potentially contributepull requests, you should avoid using pip and clone the repository instead.

pip:

The Lingvo pip package can be installed withpip3 install lingvo.

See thecodelabfor how to get started with the pip package.

From sources:

The prerequisites are:

  • a TensorFlow 2.7 installation,
  • a C++ compiler (only g++ 7.3 is officially supported), and
  • the bazel build system.

Refer to docker/dev.dockerfile for a set of workingrequirements.

git clone the repository, then use bazel to build and run targets directly.The python -m module commands in the codelab need to be mapped onto bazel run commands.

docker:

Docker configurations are available for both situations. Instructions can befound in the comments on the top of each file.

How to install docker.

Running the MNIST image model

Preparing the input data

pip:

mkdir -p /tmp/mnistpython3 -m lingvo.tools.keras2ckpt --dataset=mnist

bazel:

mkdir -p /tmp/mnistbazel run -c opt //lingvo/tools:keras2ckpt -- --dataset=mnist

The following files will be created in /tmp/mnist:

  • mnist.data-00000-of-00001: 53MB.
  • mnist.index: 241 bytes.

Running the model

pip:

cd /tmp/mnistcurl -O https://raw.githubusercontent.com/tensorflow/lingvo/master/lingvo/tasks/image/params/mnist.pypython3 -m lingvo.trainer --run_locally=cpu --mode=sync --model=mnist.LeNet5 --logdir=/tmp/mnist/log

bazel:

(cpu) bazel build -c opt //lingvo:trainer(gpu) bazel build -c opt --config=cuda //lingvo:trainerbazel-bin/lingvo/trainer --run_locally=cpu --mode=sync --model=image.mnist.LeNet5 --logdir=/tmp/mnist/log --logtostderr

After about 20 seconds, the loss should drop below 0.3 and a checkpoint will besaved, like below. Kill the trainer with Ctrl+C.

trainer.py:518] step:   205, steps/sec: 11.64 ... loss:0.25747201 ...checkpointer.py:115] Save checkpointcheckpointer.py:117] Save checkpoint done: /tmp/mnist/log/train/ckpt-00000205

Some artifacts will be produced in /tmp/mnist/log/control:

  • params.txt: hyper-parameters.
  • model_analysis.txt: model sizes for each layer.
  • train.pbtxt: the training tf.GraphDef.
  • events.*: a tensorboard events file.

As well as in /tmp/mnist/log/train:

  • checkpoint: a text file containing information about the checkpoint files.
  • ckpt-*: the checkpoint files.

Now, let's evaluate the model on the "Test" dataset. In the normal trainingsetup the trainer and evaler should be run at the same time as two separateprocesses.

pip:

python3 -m lingvo.trainer --job=evaler_test --run_locally=cpu --mode=sync --model=mnist.LeNet5 --logdir=/tmp/mnist/log

bazel:

bazel-bin/lingvo/trainer --job=evaler_test --run_locally=cpu --mode=sync --model=image.mnist.LeNet5 --logdir=/tmp/mnist/log --logtostderr

Kill the job with Ctrl+C when it starts waiting for a new checkpoint.

base_runner.py:177] No new check point is found: /tmp/mnist/log/train/ckpt-00000205

The evaluation accuracy can be found slightly earlier in the logs.

base_runner.py:111] eval_test: step:   205, acc5: 0.99775392, accuracy: 0.94150388, ..., loss: 0.20770954, ...

Running the machine translation model

To run a more elaborate model, you'll need a cluster with GPUs. Please refer tothird_party/py/lingvo/tasks/mt/README.mdfor more information.

Running the GShard transformer based giant language model

To train a GShard language model with one trillion parameters on GCP usingCloudTPUs v3-512 using 512-way model parallelism, please refer tothird_party/py/lingvo/tasks/lm/README.mdfor more information.

Running the 3d object detection model

To run the StarNet model using CloudTPUs on GCP, please refer tothird_party/py/lingvo/tasks/car/README.md.

Models

Automatic Speech Recognition

Car

Image

Language Modelling

Machine Translation

References

Please cite this paper when referencingLingvo.

@misc{shen2019lingvo,    title={Lingvo: a Modular and Scalable Framework for Sequence-to-Sequence Modeling},    author={Jonathan Shen and Patrick Nguyen and Yonghui Wu and Zhifeng Chen and others},    year={2019},    eprint={1902.08295},    archivePrefix={arXiv},    primaryClass={cs.LG}}

License

Apache License 2.0


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap