Error when exporting translator in Jupyter Notebook
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 379
- Avg merge
- 3h 30m
- Merged PRs (30d)
- 8
Description
The notebook "Transformer model for language understanding" works fine on Jupyter Notebook (WSL2 Ubuntu 18.04, Python 3.7) apart for a few warnings until the model has to be exported.
Here the following error obtains:
OperatorNotAllowedInGraphError: Iterating over a symbolic tf.Tensor is not allowed: AutoGraph did convert this function. This might indicate you are trying to use an unsupported feature.
in relation to
for i in tf.range(max_length)
in Translator class.
If I rplace tf.range(max_length) with range(max_length), as suggested elsewhere, a similar error obtains:
OperatorNotAllowedInGraphError: Using a symbolic tf.Tensor as a Python bool is not allowed: AutoGraph did convert this function. This might indicate you are trying to use an unsupported feature.
in relation to
if predicted_id == end: break
in same class.
A reason might perhaps be found in the previous warning:
WARNING: AutoGraph could not transform <bound method ExportTranslator.call of <tensorflow.python.eager.function.TfMethodTarget object at 0x7f11a7d3ffd0>> and will run it as-is.
Any hint or workaround:
thank you very much,
Giuliano
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the export failure in the “Transformer model for language understanding” notebook on the reported Jupyter Notebook setup. Trace ExportTranslator.call and the Translator loop around tf.range(max_length) and predicted_id == end; done means the translator exports without the reported symbolic-tensor errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook, python, tensorflow
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100