Skip to content

Latest commit

 

History

History
56 lines (36 loc) · 1.51 KB

README.md

File metadata and controls

56 lines (36 loc) · 1.51 KB

TensorFlow.js Example: Sequence-to-Sequence English-French Translation

This demo shows how to perform sequence-to-sequence prediction using the Layers API of TensorFlow.js.

It demonstrates loading a pretrained model hosted at a URL, using tf.loadLayersModel()

Training Demo

The training data was 149,861 English-French sentence pairs available from http://www.manythings.org/anki.

JavaScript/TypeScript Version

To train the demo in JavaScript, do

yarn train "${DATA_PATH}"

To monitor the loss values during training, use the --logDir flag in conjuction with TensorBoard, e.g.,

yarn train "${DATA_PATH}" --logDir /tmp/translation-logs

In a separate terminal, start tensorboard

pip install tensorboard   # Unless tensorboard is already installed

tensorboard --logdir /tmp/translation-logs

The model was trained in Node.js with Tensorflow.js, which the model code is converted from Python to TypeScript by @huan based on the translation.py example.

Python Version

python python/translation.py ${DATA_PATH}

The model was trained in Python Keras, based on the lstm_seq2seq example.

LAUNCH DEMO

To launch the demo, do

yarn
yarn watch

See this example live!