Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EagerTensor is not a valid JAX type #430

Closed
DevKretov opened this issue Apr 5, 2020 · 1 comment
Closed

EagerTensor is not a valid JAX type #430

DevKretov opened this issue Apr 5, 2020 · 1 comment

Comments

@DevKretov
Copy link

Description

Hello, I'm facing a problem while trying to work with Trax Trainer class. I have loaded my dataset from TFRecords file and created a Dataset instance using Dataset API. Then, I try to feed my dataset to the Trax trainer, but got this error. Could you please tell me how to accomplish this? I haven't found anything explaining how to use Dataset API with Trax library. Thanks!

Environment information

OS: Google Colab notebook

For bugs: reproduction and error logs

Steps to reproduce:

Pass dataset iterator to tras.Inputs class

Error logs:

TypeError: Argument '[[ 2 16 9 ... 0 0 0]
[ 2 16 9 ... 0 0 0]
[ 2 16 9 ... 0 0 0]
...
[ 2 70 21 ... 0 0 0]
[ 2 16 9 ... 0 0 0]
[ 2 47 14 ... 0 0 0]]' of type <class 'tensorflow.python.framework.ops.EagerTensor'> is not a valid JAX type

@lukaszkaiser
Copy link
Contributor

In Trax, the inputs are basically just python streams, not tf.Data objects. (The reason that this is possible without a big speed penalty is that JAX allows to dispatch the training step to GPU/TPU asynchronously from the python interpreter, so the python overhead is amortized by the training step.)

So to put a tf.Data into Trax, you need to convert it back to python. This is generally done by the function trax.math.dataset_to_numpy but a few tweaks may be needed to make tuples out of dicts or thing like that. In Trax, we do it here:
https://github.com/google/trax/blob/master/trax/supervised/inputs.py#L366

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants