From 2a1a0d2c59ffab51802060ce059a509a62d2690d Mon Sep 17 00:00:00 2001 From: riccardo ughi Date: Fri, 8 Oct 2021 16:09:36 +0200 Subject: [PATCH] Update NMT_with_Transformers_Reformers_using_Trax.ipynb If you choose to work with your own dataset, the generator must be infinite to prevent the train phase from being interrupted by the StopIteration event: during the generative cycle --- ..._with_Transformers_Reformers_using_Trax.ipynb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/trax/examples/NMT_with_Transformers_Reformers_using_Trax.ipynb b/trax/examples/NMT_with_Transformers_Reformers_using_Trax.ipynb index bfa4f5bfd..1a4679647 100644 --- a/trax/examples/NMT_with_Transformers_Reformers_using_Trax.ipynb +++ b/trax/examples/NMT_with_Transformers_Reformers_using_Trax.ipynb @@ -296,13 +296,15 @@ "\n", "```python\n", "def train_stream_fn():\n", - " # open the first language file (e.g. English sentences)\n", - " with open('lang1.csv','r') as f1:\n", - " # open the second language file (e.g. French sentences)\n", - " with open('lang2.csv','r') as f2:\n", - " # looping over the two files to combine the two translation toghether and yields them.\n", - " for l1, l2 in zip(f1,f2):\n", - " yield (l1, l2)\n", + " # provide an infinite generator", + " while True:", + " # open the first language file (e.g. English sentences)\n", + " with open('lang1.csv','r') as f1:\n", + " # open the second language file (e.g. French sentences)\n", + " with open('lang2.csv','r') as f2:\n", + " # looping over the two files to combine the two translation toghether and yields them.\n", + " for l1, l2 in zip(f1,f2):\n", + " yield (l1, l2)\n", "```" ] },