Git Product home page Git Product logo

translate's Introduction

PyTorch Logo


PyTorch is a Python package that provides two high-level features:

  • Tensor computation (like NumPy) with strong GPU acceleration
  • Deep neural networks built on a tape-based autograd system

You can reuse your favorite Python packages such as NumPy, SciPy, and Cython to extend PyTorch when needed.

Our trunk health (Continuous Integration signals) can be found at hud.pytorch.org.

More About PyTorch

Learn the basics of PyTorch

At a granular level, PyTorch is a library that consists of the following components:

Component Description
torch A Tensor library like NumPy, with strong GPU support
torch.autograd A tape-based automatic differentiation library that supports all differentiable Tensor operations in torch
torch.jit A compilation stack (TorchScript) to create serializable and optimizable models from PyTorch code
torch.nn A neural networks library deeply integrated with autograd designed for maximum flexibility
torch.multiprocessing Python multiprocessing, but with magical memory sharing of torch Tensors across processes. Useful for data loading and Hogwild training
torch.utils DataLoader and other utility functions for convenience

Usually, PyTorch is used either as:

  • A replacement for NumPy to use the power of GPUs.
  • A deep learning research platform that provides maximum flexibility and speed.

Elaborating Further:

A GPU-Ready Tensor Library

If you use NumPy, then you have used Tensors (a.k.a. ndarray).

Tensor illustration

PyTorch provides Tensors that can live either on the CPU or the GPU and accelerates the computation by a huge amount.

We provide a wide variety of tensor routines to accelerate and fit your scientific computation needs such as slicing, indexing, mathematical operations, linear algebra, reductions. And they are fast!

Dynamic Neural Networks: Tape-Based Autograd

PyTorch has a unique way of building neural networks: using and replaying a tape recorder.

Most frameworks such as TensorFlow, Theano, Caffe, and CNTK have a static view of the world. One has to build a neural network and reuse the same structure again and again. Changing the way the network behaves means that one has to start from scratch.

With PyTorch, we use a technique called reverse-mode auto-differentiation, which allows you to change the way your network behaves arbitrarily with zero lag or overhead. Our inspiration comes from several research papers on this topic, as well as current and past work such as torch-autograd, autograd, Chainer, etc.

While this technique is not unique to PyTorch, it's one of the fastest implementations of it to date. You get the best of speed and flexibility for your crazy research.

Dynamic graph

Python First

PyTorch is not a Python binding into a monolithic C++ framework. It is built to be deeply integrated into Python. You can use it naturally like you would use NumPy / SciPy / scikit-learn etc. You can write your new neural network layers in Python itself, using your favorite libraries and use packages such as Cython and Numba. Our goal is to not reinvent the wheel where appropriate.

Imperative Experiences

PyTorch is designed to be intuitive, linear in thought, and easy to use. When you execute a line of code, it gets executed. There isn't an asynchronous view of the world. When you drop into a debugger or receive error messages and stack traces, understanding them is straightforward. The stack trace points to exactly where your code was defined. We hope you never spend hours debugging your code because of bad stack traces or asynchronous and opaque execution engines.

Fast and Lean

PyTorch has minimal framework overhead. We integrate acceleration libraries such as Intel MKL and NVIDIA (cuDNN, NCCL) to maximize speed. At the core, its CPU and GPU Tensor and neural network backends are mature and have been tested for years.

Hence, PyTorch is quite fast — whether you run small or large neural networks.

The memory usage in PyTorch is extremely efficient compared to Torch or some of the alternatives. We've written custom memory allocators for the GPU to make sure that your deep learning models are maximally memory efficient. This enables you to train bigger deep learning models than before.

Extensions Without Pain

Writing new neural network modules, or interfacing with PyTorch's Tensor API was designed to be straightforward and with minimal abstractions.

You can write new neural network layers in Python using the torch API or your favorite NumPy-based libraries such as SciPy.

If you want to write your layers in C/C++, we provide a convenient extension API that is efficient and with minimal boilerplate. No wrapper code needs to be written. You can see a tutorial here and an example here.

Installation

Binaries

Commands to install binaries via Conda or pip wheels are on our website: https://pytorch.org/get-started/locally/

NVIDIA Jetson Platforms

Python wheels for NVIDIA's Jetson Nano, Jetson TX1/TX2, Jetson Xavier NX/AGX, and Jetson AGX Orin are provided here and the L4T container is published here

They require JetPack 4.2 and above, and @dusty-nv and @ptrblck are maintaining them.

From Source

Prerequisites

If you are installing from source, you will need:

  • Python 3.8 or later (for Linux, Python 3.8.1+ is needed)
  • A compiler that fully supports C++17, such as clang or gcc (gcc 9.4.0 or newer is required)

We highly recommend installing an Anaconda environment. You will get a high-quality BLAS library (MKL) and you get controlled dependency versions regardless of your Linux distro.

NVIDIA CUDA Support

If you want to compile with CUDA support, select a supported version of CUDA from our support matrix, then install the following:

Note: You could refer to the cuDNN Support Matrix for cuDNN versions with the various supported CUDA, CUDA driver and NVIDIA hardware

If you want to disable CUDA support, export the environment variable USE_CUDA=0. Other potentially useful environment variables may be found in setup.py.

If you are building for NVIDIA's Jetson platforms (Jetson Nano, TX1, TX2, AGX Xavier), Instructions to install PyTorch for Jetson Nano are available here

AMD ROCm Support

If you want to compile with ROCm support, install

  • AMD ROCm 4.0 and above installation
  • ROCm is currently supported only for Linux systems.

If you want to disable ROCm support, export the environment variable USE_ROCM=0. Other potentially useful environment variables may be found in setup.py.

Intel GPU Support

If you want to compile with Intel GPU support, follow these

If you want to disable Intel GPU support, export the environment variable USE_XPU=0. Other potentially useful environment variables may be found in setup.py.

Install Dependencies

Common

conda install cmake ninja
# Run this command from the PyTorch directory after cloning the source code using the “Get the PyTorch Source“ section below
pip install -r requirements.txt

On Linux

conda install intel::mkl-static intel::mkl-include
# CUDA only: Add LAPACK support for the GPU if needed
conda install -c pytorch magma-cuda121  # or the magma-cuda* that matches your CUDA version from https://anaconda.org/pytorch/repo

# (optional) If using torch.compile with inductor/triton, install the matching version of triton
# Run from the pytorch directory after cloning
# For Intel GPU support, please explicitly `export USE_XPU=1` before running command.
make triton

On MacOS

# Add this package on intel x86 processor machines only
conda install intel::mkl-static intel::mkl-include
# Add these packages if torch.distributed is needed
conda install pkg-config libuv

On Windows

conda install intel::mkl-static intel::mkl-include
# Add these packages if torch.distributed is needed.
# Distributed package support on Windows is a prototype feature and is subject to changes.
conda install -c conda-forge libuv=1.39

Get the PyTorch Source

git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
# if you are updating an existing checkout
git submodule sync
git submodule update --init --recursive

Install PyTorch

On Linux

If you would like to compile PyTorch with new C++ ABI enabled, then first run this command:

export _GLIBCXX_USE_CXX11_ABI=1

If you're compiling for AMD ROCm then first run this command:

# Only run this if you're compiling for ROCm
python tools/amd_build/build_amd.py

Install PyTorch

export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
python setup.py develop

Aside: If you are using Anaconda, you may experience an error caused by the linker:

build/temp.linux-x86_64-3.7/torch/csrc/stub.o: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status
error: command 'g++' failed with exit status 1

This is caused by ld from the Conda environment shadowing the system ld. You should use a newer version of Python that fixes this issue. The recommended Python version is 3.8.1+.

On macOS

python3 setup.py develop

On Windows

Choose Correct Visual Studio Version.

PyTorch CI uses Visual C++ BuildTools, which come with Visual Studio Enterprise, Professional, or Community Editions. You can also install the build tools from https://visualstudio.microsoft.com/visual-cpp-build-tools/. The build tools do not come with Visual Studio Code by default.

If you want to build legacy python code, please refer to Building on legacy code and CUDA

CPU-only builds

In this mode PyTorch computations will run on your CPU, not your GPU

conda activate
python setup.py develop

Note on OpenMP: The desired OpenMP implementation is Intel OpenMP (iomp). In order to link against iomp, you'll need to manually download the library and set up the building environment by tweaking CMAKE_INCLUDE_PATH and LIB. The instruction here is an example for setting up both MKL and Intel OpenMP. Without these configurations for CMake, Microsoft Visual C OpenMP runtime (vcomp) will be used.

CUDA based build

In this mode PyTorch computations will leverage your GPU via CUDA for faster number crunching

NVTX is needed to build Pytorch with CUDA. NVTX is a part of CUDA distributive, where it is called "Nsight Compute". To install it onto an already installed CUDA run CUDA installation once again and check the corresponding checkbox. Make sure that CUDA with Nsight Compute is installed after Visual Studio.

Currently, VS 2017 / 2019, and Ninja are supported as the generator of CMake. If ninja.exe is detected in PATH, then Ninja will be used as the default generator, otherwise, it will use VS 2017 / 2019.
If Ninja is selected as the generator, the latest MSVC will get selected as the underlying toolchain.

Additional libraries such as Magma, oneDNN, a.k.a. MKLDNN or DNNL, and Sccache are often needed. Please refer to the installation-helper to install them.

You can refer to the build_pytorch.bat script for some other environment variables configurations

cmd

:: Set the environment variables after you have downloaded and unzipped the mkl package,
:: else CMake would throw an error as `Could NOT find OpenMP`.
set CMAKE_INCLUDE_PATH={Your directory}\mkl\include
set LIB={Your directory}\mkl\lib;%LIB%

:: Read the content in the previous section carefully before you proceed.
:: [Optional] If you want to override the underlying toolset used by Ninja and Visual Studio with CUDA, please run the following script block.
:: "Visual Studio 2019 Developer Command Prompt" will be run automatically.
:: Make sure you have CMake >= 3.12 before you do this when you use the Visual Studio generator.
set CMAKE_GENERATOR_TOOLSET_VERSION=14.27
set DISTUTILS_USE_SDK=1
for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version [15^,17^) -products * -latest -property installationPath`) do call "%i\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=%CMAKE_GENERATOR_TOOLSET_VERSION%

:: [Optional] If you want to override the CUDA host compiler
set CUDAHOSTCXX=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64\cl.exe

python setup.py develop
Adjust Build Options (Optional)

You can adjust the configuration of cmake variables optionally (without building first), by doing the following. For example, adjusting the pre-detected directories for CuDNN or BLAS can be done with such a step.

On Linux

export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
python setup.py build --cmake-only
ccmake build  # or cmake-gui build

On macOS

export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py build --cmake-only
ccmake build  # or cmake-gui build

Docker Image

Using pre-built images

You can also pull a pre-built docker image from Docker Hub and run with docker v19.03+

docker run --gpus all --rm -ti --ipc=host pytorch/pytorch:latest

Please note that PyTorch uses shared memory to share data between processes, so if torch multiprocessing is used (e.g. for multithreaded data loaders) the default shared memory segment size that container runs with is not enough, and you should increase shared memory size either with --ipc=host or --shm-size command line options to nvidia-docker run.

Building the image yourself

NOTE: Must be built with a docker version > 18.06

The Dockerfile is supplied to build images with CUDA 11.1 support and cuDNN v8. You can pass PYTHON_VERSION=x.y make variable to specify which Python version is to be used by Miniconda, or leave it unset to use the default.

make -f docker.Makefile
# images are tagged as docker.io/${your_docker_username}/pytorch

You can also pass the CMAKE_VARS="..." environment variable to specify additional CMake variables to be passed to CMake during the build. See setup.py for the list of available variables.

make -f docker.Makefile

Building the Documentation

To build documentation in various formats, you will need Sphinx and the readthedocs theme.

cd docs/
pip install -r requirements.txt

You can then build the documentation by running make <format> from the docs/ folder. Run make to get a list of all available output formats.

If you get a katex error run npm install katex. If it persists, try npm install -g katex

Note: if you installed nodejs with a different package manager (e.g., conda) then npm will probably install a version of katex that is not compatible with your version of nodejs and doc builds will fail. A combination of versions that is known to work is [email protected] and [email protected]. To install the latter with npm you can run npm install -g [email protected]

Previous Versions

Installation instructions and binaries for previous PyTorch versions may be found on our website.

Getting Started

Three-pointers to get you started:

Resources

Communication

Releases and Contributing

Typically, PyTorch has three minor releases a year. Please let us know if you encounter a bug by filing an issue.

We appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion.

If you plan to contribute new features, utility functions, or extensions to the core, please first open an issue and discuss the feature with us. Sending a PR without discussion might end up resulting in a rejected PR because we might be taking the core in a different direction than you might be aware of.

To learn more about making a contribution to Pytorch, please see our Contribution page. For more information about PyTorch releases, see Release page.

The Team

PyTorch is a community-driven project with several skillful engineers and researchers contributing to it.

PyTorch is currently maintained by Soumith Chintala, Gregory Chanan, Dmytro Dzhulgakov, Edward Yang, and Nikita Shulga with major contributions coming from hundreds of talented individuals in various forms and means. A non-exhaustive but growing list needs to mention: Trevor Killeen, Sasank Chilamkurthy, Sergey Zagoruyko, Adam Lerer, Francisco Massa, Alykhan Tejani, Luca Antiga, Alban Desmaison, Andreas Koepf, James Bradbury, Zeming Lin, Yuandong Tian, Guillaume Lample, Marat Dukhan, Natalia Gimelshein, Christian Sarofeen, Martin Raison, Edward Yang, Zachary Devito.

Note: This project is unrelated to hughperkins/pytorch with the same name. Hugh is a valuable contributor to the Torch community and has helped with many things Torch and PyTorch.

License

PyTorch has a BSD-style license, as found in the LICENSE file.

translate's People

Contributors

alexeib avatar amyreese avatar anchit avatar arbabu123 avatar armenag avatar arustagi avatar bddppq avatar blufb avatar borguz avatar chtran avatar cndn avatar gamrix avatar gardenia22 avatar halilakin avatar jerryzh168 avatar jhcross avatar jmp84 avatar kartikayk avatar liezl200 avatar myleott avatar pmichel31415 avatar qingervt avatar rasoolims avatar stanislavglebik avatar theweiho avatar wanchaol avatar warut-vijit avatar xianxl avatar zdevito avatar zsol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

translate's Issues

Unk replacement doesn't work with the transformer

I get the following error when decoding using the transformer with --replace-unk:

Traceback (most recent call last):
  File "../../../generate.py", line 569, in <module>
    main()
  File "../../../generate.py", line 474, in main
    generate(args)
  File "../../../generate.py", line 555, in generate
    models=models, args=args, task=task, dataset_split=args.gen_subset
  File "../../../generate.py", line 142, in _generate_score
    args, task, dataset_split, translations, align_dict
  File "../../../generate.py", line 220, in _iter_first_best_bilingual
    remove_bpe=args.remove_bpe,
  File "/home/pmichel1/.local/lib/python3.6/site-packages/fairseq-0.5.0-py3.6-linux-x86_64.egg/fairseq/utils.py", line 293, in post_process_prediction
    hypo_str = replace_unk(hypo_str, src_str, alignment, align_dict, tgt_dict.unk_string())
  File "/home/pmichel1/.local/lib/python3.6/site-packages/fairseq-0.5.0-py3.6-linux-x86_64.egg/fairseq/utils.py", line 283, in replace_unk
    src_token = src_tokens[alignment[i]]
IndexError: list index out of range

nccl no more downloadable

Following your README instructions I get an error downloading nccl

wget "https://s3.amazonaws.com/pytorch/nccl_2.1.15-1%2Bcuda10.0_x86_64.txz"
--2019-09-27 14:51:33--  https://s3.amazonaws.com/pytorch/nccl_2.1.15-1%2Bcuda10.0_x86_64.txz
Resolving s3.amazonaws.com (s3.amazonaws.com)... 52.216.97.133
Connecting to s3.amazonaws.com (s3.amazonaws.com)|52.216.97.133|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2019-09-27 14:51:33 ERROR 403: Forbidden.

please help

Export a fairseq trained transformer (base) model

I trained a translation model based on scaling neural machine translation and wanted to convert into into caffe2 but when used docker image it is throwing an error ::

image

According to #60 only RNN trained models are supported ?
How about the transformer trained models .
Should I retrain again to export to caffe2 ?

ONNX export not working

pytorch_translate/examples/export_iwslt14.sh

This example doesn't work for me.
Would you be able to help me to run the example script?

I tried to fix the errors one by one, by removing parameters, but couldn't succeed to export.

  1. onnx_component_export.py: error: unrecognized arguments: --batched-beam
  2. File "/data/repos/translate/pytorch_translate/rnn.py", line 526, in build_single_decoder
    fp16=args.fp16,
    AttributeError: 'Namespace' object has no attribute 'fp16'
  3. Exception has occurred: RuntimeError
    Error(s) in loading state_dict for RNNModel: Missing key(s) in state_dict: "encoder.bilstm.layers.0.weight_ih_l0", "encoder.bilstm.layers.0.weight_hh_l0", "encoder.bilstm.layers.0.bias_ih_l0", "encoder.bilstm.layers.0.bias_hh_l0", "encoder.bilstm.layers.0.weight_ih_l0_reverse", "encoder.bilstm.layers.0.weight_hh_l0_reverse", "encoder.bilstm.layers.0.bias_ih_l0_reverse", "encoder.bilstm.layers.0.bias_hh_l0_reverse", "encoder.bilstm.layers.1.weight_ih_l0", "encoder.bilstm.layers.1.weight_hh_l0", "encoder.bilstm.layers.1.bias_ih_l0", "encoder.bilstm.layers.1.bias_hh_l0". Unexpected key(s) in state_dict: "encoder.layers.0.weight_ih_l0", "encoder.layers.0.weight_hh_l0", "encoder.layers.0.bias_ih_l0", "encoder.layers.0.bias_hh_l0", "encoder.layers.0.weight_ih_l0_reverse", "encoder.layers.0.weight_hh_l0_reverse", "encoder.layers.0.bias_ih_l0_reverse", "encoder.layers.0.bias_hh_l0_reverse", "encoder.layers.1.weight_ih_l0", "encoder.layers.1.weight_hh_l0", "encoder.layers.1.bias_ih_l0", "encoder.layers.1.bias_hh_l0".
    File "\opt\conda\lib\python3.6\site-packages\torch\nn\modules\module.py", line 771, in load_state_dict
    File "\opt\conda\lib\python3.6\site-packages\fairseq\models\fairseq_model.py", line 66, in load_state_dict
    File "D:\repos\translate\pytorch_translate\ensemble_export.py", line 122, in load_models_from_checkpoints
    File "D:\repos\translate\pytorch_translate\ensemble_export.py", line 414, in build_from_checkpoints
    File "D:\repos\translate\pytorch_translate\onnx_component_export.py", line 116, in export
    File "D:\repos\translate\pytorch_translate\onnx_component_export.py", line 88, in main
    File "D:\repos\translate\pytorch_translate\onnx_component_export.py", line 156, in

NameError: name 'LevenshteinTransformerModel' is not defined

When running bash pytorch_translate/examples/train_iwslt14.sh

Traceback (most recent call last):
  File "pytorch_translate/train.py", line 835, in <module>
    _main()
  File "pytorch_translate/train.py", line 831, in _main
    main(args)
  File "pytorch_translate/train.py", line 809, in main
    single_process_main(args, trainer_class, **train_step_kwargs)
  File "pytorch_translate/train.py", line 719, in single_process_main
    **train_step_kwargs,
  File "pytorch_translate/train.py", line 639, in train
    checkpoint_manager=checkpoint_manager,
  File "/Users/erippeth/Code/independent/onnx_junk/translate/pytorch_translate/evals.py", line 395, in save_and_eval
    averaged_params=averaged_params,
  File "/Users/erippeth/Code/independent/onnx_junk/translate/pytorch_translate/evals.py", line 181, in evaluate_bleu
    model_params=averaged_params,
  File "/Users/erippeth/Code/independent/onnx_junk/translate/pytorch_translate/evals.py", line 275, in calculate_bleu_on_subset
    modify_target_dict=False,
  File "/Users/erippeth/Code/independent/onnx_junk/translate/pytorch_translate/generate.py", line 101, in generate_score
    modify_target_dict=modify_target_dict,
  File "/Users/erippeth/Code/independent/onnx_junk/translate/pytorch_translate/generate.py", line 178, in _generate_score
    translator = build_sequence_generator(args, task, models)
  File "/Users/erippeth/Code/independent/onnx_junk/translate/pytorch_translate/generate.py", line 136, in build_sequence_generator
    elif isinstance(models[0], LevenshteinTransformerModel):
NameError: name 'LevenshteinTransformerModel' is not defined

The culprit is this fella: https://github.com/pytorch/translate/blob/master/pytorch_translate/generate.py#L48

Because the import is conditional, there's a name error when the import fails.

Error when exporting checkpoint: 'Namespace' has no 'residual_level'

I used the docker image to train a model, but when I tried to export it I got this error message:

Ignoring @/caffe2/caffe2/contrib/aten:aten_op as it is not a valid file.
Traceback (most recent call last):
  File "pytorch_translate/onnx_component_export.py", line 124, in <module>
    main()
  File "pytorch_translate/onnx_component_export.py", line 86, in main
    dst_dict_filename=args.dst_dict,
  File "/home/translate/pytorch_translate/ensemble_export.py", line 236, in build_from_checkpoints
    dst_dict_filename,
  File "/home/translate/pytorch_translate/ensemble_export.py", line 62, in load_models_from_checkpoints
    dst_dict,
  File "/home/translate/pytorch_translate/rnn.py", line 218, in build_model
    residual_level=args.residual_level,
AttributeError: 'Namespace' object has no attribute 'residual_level'

I also got this error message previously when I tried to export checkpoints from models I'd trained with fairseq-py - I assumed it just meant this wasn't supported, but since it happens on models trained with this project as well it's maybe a bug.

The command I used to export was:

#!/bin/bash

export NCCL_ROOT_DIR="$(pwd)/nccl_2.1.15-1+cuda8.0_x86_64"
export LD_LIBRARY_PATH="${NCCL_ROOT_DIR}/lib:${LD_LIBRARY_PATH}"
python3 pytorch_translate/onnx_component_export.py \
    --checkpoint mounted/checkpoints/checkpoint_best.pt \
    --encoder_output_file mounted/export/encoder.pb \
    --decoder_output_file mounted/export/decoder.pb \
    --src_dict mounted/checkpoints/dictionary-in.txt \
    --dst_dict mounted/checkpoints/dictionary-out.txt \
    --beam_size 6 \
    --word_penalty 0.25 \
    --unk_penalty -0.5 \
    --batched_beam && \
  echo "Finished exporting encoder as ./encoder.pb and decoder as ./decoder.pb"

The command I used to train this model was:

#!/bin/bash

export NCCL_ROOT_DIR="$(pwd)/nccl_2.1.15-1+cuda8.0_x86_64"
export LD_LIBRARY_PATH="${NCCL_ROOT_DIR}/lib:${LD_LIBRARY_PATH}"
CUDA_VISIBLE_DEVICES=0 python3 pytorch_translate/train.py \
   "" \
   --arch fconv_iwslt_de_en \
   --lr-scheduler reduce_lr_on_plateau \
   --lr-shrink 0.1 \
   --max-epoch 20 \
   --optimizer nag \
   --lr 0.3 \
   --clip-norm 0.1 \
   --criterion cross_entropy \
   --batch-size 256 \
   --max-tokens 3000 \
   --save-dir /home/translate/mounted/checkpoints \
   --beam 5 \
   --source-lang in \
   --target-lang out \
   --source-vocab-file /home/translate/mounted/checkpoints/dictionary-in.txt \
   --target-vocab-file /home/translate/mounted/checkpoints/dictionary-out.txt \
   --train-source-text-file /home/translate/mounted/bpe/train.in \
   --train-target-text-file /home/translate/mounted/bpe/train.out \
   --eval-source-text-file /home/translate/mounted/bpe/valid.in \
   --eval-target-text-file /home/translate/mounted/bpe/valid.out \
   --log-interval 1000 \
   2>&1 | tee -a /home/translate/mounted/checkpoints/log

I notice the error is in rnn.py, but I don't use an rnn, but an fconv model. Are these models not yet supported for export?

Exporting model status

What is the current roadmap and status for export to Caffe2?
Currently I cannot build as missing files, build scripts.
Also in other issue it is said that next commit, the export will be using TorchScript instead?

While running pretrained model(IWSLT 2014) , observed below errors

Traceback (most recent call last):
File "pytorch_translate/generate.py", line 705, in
main()
File "pytorch_translate/generate.py", line 609, in main
generate(args)
File "pytorch_translate/generate.py", line 634, in generate
args.path.split(":")
File "/root/pytorch/fairseq/pytorch-translate/translate/pytorch_translate/utils.py", line 116, in load_diverse_ensemble_for_inference
task = tasks.setup_task(checkpoints_data[0]["args"])
File "/root/pytorch/fairseq/fairseq/tasks/init.py", line 19, in setup_task
return TASK_REGISTRY[args.task].setup_task(args, **kwargs)
File "/root/pytorch/fairseq/pytorch-translate/translate/pytorch_translate/tasks/pytorch_translate_task.py", line 124, in setup_task
args.source_vocab_file
File "/root/pytorch/fairseq/fairseq/data/dictionary.py", line 184, in load
d.add_from_file(f, ignore_utf_errors)
File "/root/pytorch/fairseq/fairseq/data/dictionary.py", line 201, in add_from_file
raise fnfe
File "/root/pytorch/fairseq/fairseq/data/dictionary.py", line 195, in add_from_file
with open(f, 'r', encoding='utf-8') as fd:
FileNotFoundError: [Errno 2] No such file or directory: 'checkpoints/dictionary-de.txt'

Unable to export model

Hi,
After following instructions given in https://github.com/pytorch/translate#install-translate-from-source
I ran https://github.com/pytorch/translate/blob/master/pytorch_translate/examples/train_iwslt14.sh and also succesfully exported the model using https://github.com/pytorch/translate/blob/master/pytorch_translate/examples/export_iwslt14.sh to generate .pb files. But when I try to run echo "hallo welt" | bash pytorch_translate/examples/translate_iwslt14.sh
I get error saying that there is no translation_decoder in cpp/build directory. Did I do any mistake please elaborate the procedure so that the export to Caffe2 is easily reproducable.
Thanks in advance.

beam search

According to README:

Currently, we export components (encoder, decoder) to Caffe2 separately and beam search is implemented in C++. In the near future, we will be able to export the beam search as well. We also plan to add export support to more models.

Where can I find this C++ code or exportable (jit) beam search already in repo?

unrecognized arguments: --batched-beam

It looks like --batched-beam has been removed from the ONNX export:

$ bash pytorch_translate/examples/export_iwslt14.sh

...

WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
usage: onnx_component_export.py [-h] [--path FILE]
                                [--encoder-output-file ENCODER_OUTPUT_FILE]
                                [--decoder-output-file DECODER_OUTPUT_FILE]
                                --source-vocab-file SOURCE_VOCAB_FILE
                                --target-vocab-file TARGET_VOCAB_FILE
                                [--beam-size BEAM_SIZE]
                                [--word-reward WORD_REWARD]
                                [--unk-reward UNK_REWARD] [--char-source]
onnx_component_export.py: error: unrecognized arguments: --batched-beam

RNN decode results are batch-size dependent

Using an RNN model (similar to the example architecture), smaller batch sizes produce better results with generate.py. It looks like a padding error, the best results occur with a batch size of 1 (no batching).

I attempted to reproduce with the example scripts but that model seems out of date and would not run.

Following instructions to install gives compiler errors when building python on Ubuntu

Hello,

I tried to follow the instructions in the readme to install. First, I used my existing anaconda environment. However, it failed during the build of pytorch, the linker complaining about missing -pthreads among other things. I did some searching and found that maybe the anaconda compilers weren't installed, so I tried to install them with

conda install gcc_linux-64 gxx_linux-64 gfortran_linux-64

However, this was apparently the wrong compilers, since the build immediately failed with two unrecognized command line options: -fstack-protector-strong and -fno-plt

After that I thought I'd try using a fresh miniconda environment rather than my existing anaconda environment, so I did it over with following the miniconda installation steps in the README too. This time, it fails with linker being unable to find -lgcc_s, which again sounds a lot like a missing compiler install. Trying to install them with the same command line as above gives the same error.

Installing FAIR's tools - which are fantastic once I get them to work, thank you! - appear to be extremely sensitive to C++ compiler versions. The same with nvidia's tools... I stranded on this problem last time I tried to install pytorch from source, however then the new nightly build distributions of pytorch saved me then.

If you could provide similar bleeding edge binaries for ONNX and Caffe2, that'd be terrific! If not, if the build files could make sure the right compiler was used (and give sensible error messages if not) that would be a big improvement too.

Generating with replace-unk is broken

I get the following error:

  File "../../../generate.py", line 200, in _iter_first_best_bilingual
    target_str = task.dataset(dataset_split).dst.get_original_text(sample_id)
AttributeError: 'LanguagePairDataset' object has no attribute 'dst'

Most likely an artifact of the fairseq update

Unable to import onxx

When trying to export PyTorch model to a Caffe2 graph via ONNX, the script throws an error on importing onxx.
Import Error: undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameEv
Kindly help explain the issue and also provide solution for the same.

obtain alignment/attention information

I would like to access information on alignment or even the full attention matrix. This is possible with the fairseq CLI (with the print-alignment flag) and to some extent also in the python interface to fairsec (as logging messages).
Is there a way to obtain this information with pytorch-translate?

pytorch

What is the version of pytorch

fairseq version 0.5.0 requirement

It seems that on 12 jun there was a major update to fairseq, changing the library structure, and Translate has already started using this. The fairseq package installed in my miniconda environment following the installation instructions is 0.4.0. Running any translate command fails with

from fairseq import (
ImportError: cannot import name 'tasks'

I think this old version of fairseq was installed as part of the combined PyTorch and Caffe2 Conda package. pip/conda don't know about the newer version.

Could you update the installation instructions so that the current version of Translate can be run?

ONNX export of RNN failed, Cannot export individual pack_padded_sequence/pad_packed_sequence

The new RNN model I trained didn't export properly, I got this error message:

Ignoring @/caffe2/caffe2/contrib/aten:aten_op as it is not a valid file.
Traceback (most recent call last):
  File "pytorch_translate/onnx_component_export.py", line 124, in <module>
    main()
  File "pytorch_translate/onnx_component_export.py", line 89, in main
    encoder_ensemble.save_to_db(args.encoder_output_file)
  File "/home/translate/pytorch_translate/ensemble_export.py", line 213, in save_to_db
    self.onnx_export(tmp_file)
  File "/home/translate/pytorch_translate/ensemble_export.py", line 204, in onnx_export
    output_names=self.output_names,
  File "/home/translate/pytorch_translate/ensemble_export.py", line 44, in onnx_export_ensemble
    output_names=output_names,
  File "/home/miniconda/lib/python3.6/site-packages/torch/onnx/__init__.py", line 20, in _export
    return utils._export(*args, **kwargs)
  File "/home/miniconda/lib/python3.6/site-packages/torch/onnx/utils.py", line 207, in _export
    proto, export_map = graph.export(params, _onnx_opset_version, defer_weight_export, export_raw_ir)
RuntimeError: ONNX export failed: Cannot export individual pack_padded_sequence or pad_packed_sequence; these operations must occur in pairs.

... followed by a long stacktrace.

The model was trained with this command line/script, based on the example:

#!/bin/bash

export NCCL_ROOT_DIR="$(pwd)/nccl_2.1.15-1+cuda8.0_x86_64"
export LD_LIBRARY_PATH="${NCCL_ROOT_DIR}/lib:${LD_LIBRARY_PATH}"
CUDA_VISIBLE_DEVICES=0 python3 pytorch_translate/train.py \
   "" \
   --arch rnn \
   --lr-scheduler fixed \
   --force-anneal 200 \
   --max-epoch 100 \
   --stop-time-hr 72 \
   --optimizer sgd \
   --lr 0.5 \
   --clip-norm 5.0 \
   --criterion label_smoothed_cross_entropy \
   --batch-size 256 \
   --lenpen 0 \
   --unkpen 0.5 \
   --word-reward 0.25 \
   --max-tokens 3000 \
   --encoder-layers 2 \
   --encoder-embed-dim 256 \
   --encoder-hidden-dim 512 \
   --decoder-layers 2 \
   --decoder-embed-dim 256 \
   --decoder-hidden-dim 512 \
   --decoder-out-embed-dim 256 \
   --save-dir /home/translate/mounted/checkpoints \
   --attention-type dot \
   --sentence-avg \
   --momentum 0 \
   --generate-bleu-eval-avg-checkpoints 10 \
   --generate-bleu-eval-per-epoch \
   --beam 6 \
   --no-beamable-mm \
   --source-lang in \
   --target-lang out \
   --source-vocab-file /home/translate/mounted/checkpoints/dictionary-in.txt \
   --target-vocab-file /home/translate/mounted/checkpoints/dictionary-out.txt \
   --train-source-text-file /home/translate/mounted/bpe/train.in \
   --train-target-text-file /home/translate/mounted/bpe/train.out \
   --eval-source-text-file /home/translate/mounted/bpe/valid.in \
   --eval-target-text-file /home/translate/mounted/bpe/valid.out \
   --source-max-vocab-size 14000 \
   --target-max-vocab-size 14000 \
   --log-interval 500 \
   2>&1 | tee -a /home/translate/mounted/checkpoints/log

(I see now that I forgot to make it an LSTM, wow. How did I even get good results?)

The export command was exactly the same as the example, only the path being different and the download being removed. I tried exporting many different checkpoints, averaged and not.

During Build Translate step i am getting this error, should i start all over again?

Btw this notice that caffe installed never failed but it got successfully ended at 18% . it was shocking to me but i let is go on ..

Current error is below

`(base) test@dc-isb-ds-001:~/Downloads/translate/pytorch_translate/cpp/build$ cmake \

-DCMAKE_PREFIX_PATH="${CONDA_PATH}/usr/local"
-DCMAKE_INSTALL_PREFIX="${CONDA_PATH}" ..
2>&1 | tee CMAKE_OUT
CMake Error at CMakeLists.txt:8 (find_package):
By not providing "FindCaffe2.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Caffe2", but
CMake did not find one.

Could not find a package configuration file provided by "Caffe2" with any
of the following names:

Caffe2Config.cmake
caffe2-config.cmake

Add the installation prefix of "Caffe2" to CMAKE_PREFIX_PATH or set
"Caffe2_DIR" to a directory containing one of the above files. If "Caffe2"
provides a separate development package or SDK, be sure it has been
installed.

-- Configuring incomplete, errors occurred!
See also "/home/test/Downloads/translate/pytorch_translate/cpp/build/CMakeFiles/CMakeOutput.log".
`

Cannot load pretrained model

When I try to load the pretrained iwslt de-en model, I see an exception:

>>> import torch
>>> from fairseq.models.transformer import TransformerModel
>>> model = TransformerModel.from_pretrained("./", "averaged_checkpoint_best_0.pt")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/erippeth/miniconda3/envs/fairseq-dev/lib/python3.6/site-packages/fairseq/models/fairseq_model.py", line 218, in from_pretrained
    **kwargs,
  File "/Users/erippeth/miniconda3/envs/fairseq-dev/lib/python3.6/site-packages/fairseq/hub_utils.py", line 73, in from_pretrained
    arg_overrides=kwargs,
  File "/Users/erippeth/miniconda3/envs/fairseq-dev/lib/python3.6/site-packages/fairseq/checkpoint_utils.py", line 202, in load_model_ensemble_and_task
    state = load_checkpoint_to_cpu(filename, arg_overrides)
  File "/Users/erippeth/miniconda3/envs/fairseq-dev/lib/python3.6/site-packages/fairseq/checkpoint_utils.py", line 175, in load_checkpoint_to_cpu
    state = _upgrade_state_dict(state)
  File "/Users/erippeth/miniconda3/envs/fairseq-dev/lib/python3.6/site-packages/fairseq/checkpoint_utils.py", line 366, in _upgrade_state_dict
    registry.set_defaults(state["args"], tasks.TASK_REGISTRY[state["args"].task])
KeyError: 'pytorch_translate'

Do I need to retrain this model because of API changes or am I doing something wrong in loading?

depricated functions

p3 instance on AWS
Ubuntu 18.04
torch: 1.5.0.dev20200304
fairseq: 0.9.0
pytorch-translate: 0.1.0

from ~/translate
I run

bash pytorch-translate/examples/train-transformer.sh

where train-transformer.sh is:

#!/bin/bash

NCCL_ROOT_DIR="$(pwd)/nccl_2.1.15-1+cuda-10.1"
export NCCL_ROOT_DIR
LD_LIBRARY_PATH="${NCCL_ROOT_DIR}/lib:${LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH
wget https://download.pytorch.org/models/translate/iwslt14/data.tar.gz
tar -xvzf data.tar.gz
rm -rf checkpoints data.tar.gz && mkdir -p checkpoints
CUDA_VISIBLE_DEVICES=0 python3 pytorch_translate/train.py
""
--arch ptt_transformer
--lr-scheduler inverse_sqrt
--log-verbose
--max-epoch 100
--stop-time-hr 72
--stop-no-best-bleu-eval 5
--optimizer adam
--lr 5e-4
--clip-norm 5.0
--criterion label_smoothed_cross_entropy
--label-smoothing 0.1
--batch-size 128
--length-penalty 0
--unk-reward -0.5
--word-reward 0.25
--max-tokens 4096
--save-dir checkpoints
--adam-betas '(0.9, 0.98)'
--num-avg-checkpoints 10
--beam 2
--no-beamable-mm
--source-lang de
--target-lang en
--train-source-text-file data/train.tok.bpe.de
--train-target-text-file data/train.tok.bpe.en
--dropout 0.3
--attention-dropout 0.3
--relu-dropout 0.3
--encoder-embed-dim 256
--encoder-ffn-embed-dim 256
--encoder-layers 4
--encoder-attention-heads 4
--decoder-embed-dim 256
--decoder-ffn-embed-dim 256
--decoder-layers 4
--decoder-attention-heads 4
--decoder-layerdrop 0.3
--eval-source-text-file data/valid.tok.bpe.de
--eval-target-text-file data/valid.tok.bpe.en
--source-max-vocab-size 14000
--target-max-vocab-size 14000
--log-interval 10
--seed "${RANDOM}"
2>&1 | tee -a checkpoints/log

I get:

...
[2020-03-08 18:16:15.546057] | Finished removing old checkpoint checkpoints/checkpoint100_end.pt.
pytorch_translate/train.py:693: UserWarning: Trainer.get_meter is deprecated. Please use fairseq.metrics instead.
  meter = trainer.get_meter(k)
/opt/conda/conda-bld/pytorch_1583309282142/work/torch/csrc/utils/python_arg_parser.cpp:739: UserWarning: This overload of add_ is deprecated:
	add_(Number alpha, Tensor other)
Consider using one of the following signatures instead:
	add_(Tensor other, Number alpha)
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/home/ubuntu/miniconda/lib/python3.7/site-packages/fairseq-0.9.0-py3.7-linux-x86_64.egg/fairseq/logging/progress_bar.py", line 299, in _close_writers
    for w in _tensorboard_writers.values():
NameError: name '_tensorboard_writers' is not defined

unexpected keyword argument 'max_tokens'

I followed "Quickstart" section to install the framework.
When I run default training example (bash pytorch_translate/examples/train_iwslt14.sh) I get following error:

Traceback (most recent call last):
  File "pytorch_translate/train.py", line 974, in <module>
    main(args, single_process_main)
  File "pytorch_translate/train.py", line 945, in main
    return single_process_train(args)
  File "pytorch_translate/train.py", line 332, in single_process_main
    extra_state, trainer, task, epoch_itr = setup_training(args)
  File "pytorch_translate/train.py", line 285, in setup_training
    shard_id=args.distributed_rank,
TypeError: __init__() got an unexpected keyword argument 'max_tokens'

I am not quite sure what is exact problem here...
Please tell me if you need any additional information.

adv_train.py can't work well

I found that there are some errors when I run adv_train.py, some functions used in adv_train.py do not match the current version.

Unable - pull the docker

HI Team,

I am not pull Translate image from Docker. it is throwing error "unauthorized: authentication required". Can you please help us on this?

Here is Log

docker pull pytorch/translate

Using default tag: latest
latest: Pulling from pytorch/translate
297061f60c36: Pull complete
e9ccef17b516: Pull complete
dbc33716854d: Pull complete
8fe36b178d25: Pull complete
686596545a94: Pull complete
f611dfbee954: Pull complete
c51814f3e9ba: Pull complete
5da0fc07e73a: Pull complete
97462b1887aa: Extracting 64.06MB/477MB
924ea239f6fe: Downloading 469.4MB/585.2MB
f4a08faeb019: Download complete
d2a2cd1e3b42: Download complete
d714aef7a6eb: Download complete
a525fe235307: Downloading 62.29MB/69.73MB
6657161af193: Downloading
1839b2f91735: Waiting
a6034776fbac: Waiting
d1470d258ff1: Waiting
cff0a26dca2d: Waiting
4d6715d99c6a: Waiting

unauthorized: authentication required

How can I export a single Onnx?

hi,

Sorry to bother you, I want to export the Onnx model using fairseq, and I see that you have implemented this function in your code.
I see your code that use onnx as the medium and them export to caffe2. But the result are divided into encoder and decoder. May I ask why it needs to divided into 2 parts? And how can I output a single entire model?

thanks

build translate fail under gcc 5.3.1

when i build translate with cuda 9.0, i meet below issues, did anyone meet the same issue?

-- The C compiler identification is GNU 5.3.1
-- The CXX compiler identification is GNU 5.3.1
-- Check for working C compiler: /opt/rh/devtoolset-4/root/usr/bin/cc
-- Check for working C compiler: /opt/rh/devtoolset-4/root/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /opt/rh/devtoolset-4/root/usr/bin/c++
-- Check for working CXX compiler: /opt/rh/devtoolset-4/root/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Caffe2: Found gflags with new-style gflags target.
-- Caffe2: Cannot find glog automatically. Using legacy find.
-- Found glog: /usr/include
-- Caffe2: Found glog (include: /usr/include, library: /usr/lib64/libglog.so)
-- Caffe2: Found protobuf with new-style protobuf targets.
-- Caffe2: Protobuf version 3.5.0
-- Found CUDA: /usr/local/cuda (found suitable version "9.0", minimum required is "7.0")
-- Caffe2: CUDA detected: 9.0
-- Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc
-- Caffe2: CUDA toolkit directory: /usr/local/cuda
-- Caffe2: Header version is: 9.0
-- Found CUDNN: /usr/local/cuda/include
-- Found cuDNN: v7.1.2 (include: /usr/local/cuda/include, library: /usr/local/cuda/lib64/libcudnn.so)
-- Autodetected CUDA architecture(s): 6.0
-- Added CUDA NVCC flags for: -gencode;arch=compute_60,code=sm_60
-- Summary:
-- CMake version : 3.11.1
-- CMake command : /home/wliao2/local/bin/cmake
-- System name : Linux
-- C++ compiler : /opt/rh/devtoolset-4/root/usr/bin/c++
-- C++ compiler version : 5.3.1
-- CXX flags : -std=c++11 -O2 -fPIC -Wno-narrowing
-- Caffe2 version : 0.8.2
-- Caffe2 include path : /home/wliao2/anaconda3/envs/translate/include
-- Have CUDA :
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wliao2/translate/pytorch_translate/cpp/build
(translate) [xxx]$ make 2>&1 | tee MAKE_OUT
Scanning dependencies of target translation_decoder
[ 16%] Building CXX object CMakeFiles/translation_decoder.dir/Decoder.cpp.o
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:38:18: error: expected constructor, destructor, or type conversion before ‘(’ token
C10_DEFINE_string(encoder_model, "", "Encoder model path");
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:39:18: error: expected constructor, destructor, or type conversion before ‘(’ token
C10_DEFINE_string(decoder_step_model, "", "Decoder step model path");
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:40:18: error: expected constructor, destructor, or type conversion before ‘(’ token
C10_DEFINE_string(source_vocab_path, "", "Source vocab file");
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:41:18: error: expected constructor, destructor, or type conversion before ‘(’ token
C10_DEFINE_string(target_vocab_path, "", "Target vocab file");
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:43:15: error: expected constructor, destructor, or type conversion before ‘(’ token
C10_DEFINE_int(beam_size, -1, "Beam size");
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:44:18: error: expected constructor, destructor, or type conversion before ‘(’ token
C10_DEFINE_double(
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:50:15: error: expected constructor, destructor, or type conversion before ‘(’ token
C10_DEFINE_int(
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:57:16: error: expected constructor, destructor, or type conversion before ‘(’ token
C10_DEFINE_bool(
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:61:16: error: expected constructor, destructor, or type conversion before ‘(’ token
C10_DEFINE_bool(
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:65:16: error: expected constructor, destructor, or type conversion before ‘(’ token
C10_DEFINE_bool(
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:69:18: error: expected constructor, destructor, or type conversion before ‘(’ token
C10_DEFINE_double(
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp: In function ‘int main(int, char**)’:
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:78:7: error: ‘FLAGS_source_vocab_path’ is not a member of ‘c10’
if (c10::FLAGS_source_vocab_path.empty() ||
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:79:7: error: ‘FLAGS_target_vocab_path’ is not a member of ‘c10’
c10::FLAGS_target_vocab_path.empty() ||
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:80:7: error: ‘FLAGS_encoder_model’ is not a member of ‘c10’
c10::FLAGS_encoder_model.empty() ||
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:81:7: error: ‘FLAGS_decoder_step_model’ is not a member of ‘c10’
c10::FLAGS_decoder_step_model.empty()) {
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:85:38: error: ‘FLAGS_source_vocab_path’ is not a member of ‘c10’
<< "(source_vocab_path='" << c10::FLAGS_source_vocab_path
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:86:40: error: ‘FLAGS_target_vocab_path’ is not a member of ‘c10’
<< "', target_vocab_path='" << c10::FLAGS_target_vocab_path
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:87:36: error: ‘FLAGS_encoder_model’ is not a member of ‘c10’
<< "', encoder_model='" << c10::FLAGS_encoder_model
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:88:41: error: ‘FLAGS_decoder_step_model’ is not a member of ‘c10’
<< "', decoder_step_model='" << c10::FLAGS_decoder_step_model << "')";
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:92:41: error: ‘FLAGS_source_vocab_path’ is not a member of ‘c10’
std::make_sharedpyt::Dictionary(c10::FLAGS_source_vocab_path);
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:94:41: error: ‘FLAGS_target_vocab_path’ is not a member of ‘c10’
std::make_sharedpyt::Dictionary(c10::FLAGS_target_vocab_path);
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:96:7: error: ‘FLAGS_beam_size’ is not a member of ‘c10’
c10::FLAGS_beam_size,
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:97:7: error: ‘FLAGS_max_out_seq_len_mult’ is not a member of ‘c10’
c10::FLAGS_max_out_seq_len_mult,
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:98:7: error: ‘FLAGS_max_out_seq_len_bias’ is not a member of ‘c10’
c10::FLAGS_max_out_seq_len_bias,
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:101:7: error: ‘FLAGS_encoder_model’ is not a member of ‘c10’
c10::FLAGS_encoder_model,
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:102:7: error: ‘FLAGS_decoder_step_model’ is not a member of ‘c10’
c10::FLAGS_decoder_step_model,
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:103:7: error: ‘FLAGS_reverse_source’ is not a member of ‘c10’
c10::FLAGS_reverse_source,
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:104:7: error: ‘FLAGS_stop_at_eos’ is not a member of ‘c10’
c10::FLAGS_stop_at_eos,
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:105:7: error: ‘FLAGS_append_eos_to_source’ is not a member of ‘c10’
c10::FLAGS_append_eos_to_source,
^
/home/wliao2/translate/pytorch_translate/cpp/Decoder.cpp:106:7: error: ‘FLAGS_length_penalty’ is not a member of ‘c10’
c10::FLAGS_length_penalty);
^
make[2]: *** [CMakeFiles/translation_decoder.dir/Decoder.cpp.o] Error 1
make[1]: *** [CMakeFiles/translation_decoder.dir/all] Error 2
make: *** [all] Error 2

Training Knowledge distillation with model trained on Fairseq

Hi ,
I have trained a En-De model using fairseq and now want to try the knowledge_distillation task to train the student model on reduced transformer architecture.I was however unable to do so. I wanted to know whether this is possible i.e., training teacher on fairseq and student in translate libraries. Or should the teacher be also trained on translate library. Kindly clarify. Also I am trying to do knowledge_distillation task and I am confused on how to give inputs.
Say I have model , binaries and dictionaries generated from walkthrough in fairseq. How can I use them from knowledge distillation. Are they enough or should I also need the logits saved in file and how should I use them please elaborate.
Thanks

Cannot import 'latent_var_criterion'

Hi,
After installing translate, when I try:
bash pytorch_translate/examples/train_iwslt14.sh
It shows this error:
Traceback (most recent call last): File "pytorch_translate/train.py", line 22, in <module> from pytorch_translate import latent_var_criterion # noqa ImportError: cannot import name 'latent_var_criterion' from 'pytorch_translate'

How to solve it?
Thanks.

Are there any example of deep fusion?

class DeepFusionStrategy(MultiDecoderCombinationStrategy) seems that it's an implementation of deep fusion, but I'm not sure how to use it.

Could you please show me an example of deep fusion parameters exactly, like train_iwslt14.sh?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.