Search code examples
pythontrax

Select task from Trax loop


I have a Trax loop object, from which I would like to extract a task object. The code below returns the error AttributeError: 'Loop' object has no attribute '_task'. Do you have suggestions on how to fix this?

Background info: I am trying to run on a GPU setting the code of W4 assignement of the Coursera course "Natural Language Processign with Attention Models".

test_loop = training_loop(ReformerLM, train_stream, eval_stream)
type(test_loop)
train_task = test_loop._task

Here is the error message:

<class 'trax.supervised.training.Loop'>

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-34-937f26e690d0> in <module>
      1 test_loop = training_loop(ReformerLM, train_stream, eval_stream)
      2 print(type(test_loop))
----> 3 train_task = test_loop._task
      4 #eval_task = test_loop._eval_task
      5 

AttributeError: 'Loop' object has no attribute '_task'

Solution

  • No access to the coursera course:/, can you try the following properties?

    1. test_loop.tasks, which returns the training tasks.
    2. test_loop.eval_tasks, which returns the evaluation tasks.

    You can find more properties from trax doc: https://trax-ml.readthedocs.io/en/latest/trax.supervised.html#trax.supervised.training.Loop.tasks