Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit 96f72d4

Browse files
iislucasrsepassi
authored andcommitted
Updated instructions & bugfix in new Problem docs (#490)
* Add helpful (I think) instructions & bugfix * Added some instructions for using pip to create editable install so you can locally test. * Also added commands to run the local test. * Fixed bug with accidental `self` argument in hparams definition. * code review comment fixes * tweak language * typos and more tweaks
1 parent c1cd875 commit 96f72d4

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

docs/new_problem.md

+26-3
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,40 @@ All hyperparamters inherit from `_default_hparams()` in `problem.py.` If you wou
240240
from tensor2tensor.models import transformer
241241

242242
@registry.register_hparams
243-
def word2def_hparams(self):
243+
def word2def_hparams():
244244
hparams = transformer.transformer_base_single_gpu() # Or whatever you'd like to build off.
245245
hparams.batch_size = 1024
246246
return hparams
247247
```
248248

249+
# Test the data generation
250+
251+
You can test data generation of your a problem in your own project with:
252+
253+
```bash
254+
PROBLEM=word2def
255+
DATA_DIR=$HOME/t2t_data
256+
TMP_DIR=/tmp/t2t_datagen
257+
mkdir -p $DATA_DIR $TMP_DIR
258+
259+
t2t-datagen \
260+
--t2t_usr_dir=$PATH_TO_YOUR_PROBLEM_DIR \
261+
--data_dir=$DATA_DIR \
262+
--tmp_dir=$TMP_DIR \
263+
--problem=$PROBLEM
264+
```
265+
266+
Where:
267+
* `PROBLEM` is the name of the class that was registered with `@registry.register_problem()`, but converted from `CamelCase` to `snake_case`.
268+
* `PATH_TO_YOUR_PROBLEM_DIR` is a path to the directory of your python problem file.
269+
270+
If you plan to contribute to the tensor2tensor repository, you can install the local cloned version in developer mode with `pip install -e .` from the tensor2tensor directory. You can also add your new problem file to [`all_problems.py`](https://github.com/tensorflow/tensor2tensor/blob/master/tensor2tensor/data_generators/all_problems.py).
271+
249272
# Run the problem
250273
Now that we've gotten our problem set up, let's train a model and generate definitions.
251274

252-
We specify our problem name, the model, and hparams.
275+
To train, specify the problem name, the model, and hparams:
276+
253277
```bash
254278
PROBLEM=word2def
255279
MODEL=transformer
@@ -258,7 +282,6 @@ HPARAMS=word2def_hparams
258282

259283
The rest of the steps are as given in the [walkthrough](walkthrough.md).
260284

261-
262285
What if we wanted to train a model to generate words given definitions? In T2T, we can change the problem name to be `PROBLEM=word2def_rev`.
263286

264287
All done. Let us know what definitions your model generated.

0 commit comments

Comments
 (0)