Skip to content

Files

Latest commit

e2773bc · Jun 10, 2022

History

History
This branch is 192 commits behind tensorflow/tfjs-examples:master.

translation

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jan 6, 2019
Mar 13, 2019
Jan 3, 2022
Mar 13, 2019
Mar 13, 2019
Mar 13, 2019
Mar 21, 2022
Nov 28, 2018
Feb 21, 2019
Jun 10, 2022
Mar 21, 2022
Mar 19, 2019
Mar 13, 2019
Nov 28, 2018
Apr 14, 2022

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!