TypeError: 'FullTransformerBatch' object is not iterable

Hi!

Firstly, thanks very much for this great product and support which is very useful and efficient for my research!

I am trying to use en_core_web_trf base model, but I keep receiving the following error (There is no problem when I use en_core_web_lg).

TypeError("'FullTransformerBatch' object is not iterable")
Traceback (most recent call last):
  File "C:\Users\Asli\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Asli\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\prodigy\__main__.py", line 61, in <module>
    controller = recipe(*args, use_plac=True)
  File "cython_src\prodigy\core.pyx", line 325, in prodigy.core.recipe.recipe_decorator.recipe_proxy
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\plac_core.py", line 367, in call
    cmd, result = parser.consume(arglist)
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\plac_core.py", line 232, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\prodigy\recipes\train.py", line 283, in train
    silent=silent,
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\prodigy\recipes\train.py", line 197, in _train
    spacy_train(nlp, output_path, use_gpu=gpu_id, stdout=stdout)
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\spacy\training\loop.py", line 122, in train
    raise e
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\spacy\training\loop.py", line 105, in train
    for batch, info, is_best_checkpoint in training_step_iterator:
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\spacy\training\loop.py", line 224, in train_while_improving
    score, other_scores = evaluate()
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\spacy\training\loop.py", line 281, in evaluate
    scores = nlp.evaluate(dev_corpus(nlp))
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\spacy\language.py", line 1385, in evaluate
    examples,
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\spacy\util.py", line 1488, in _pipe
    yield from proc.pipe(docs, **kwargs)
  File "spacy\pipeline\trainable_pipe.pyx", line 79, in pipe
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\spacy\util.py", line 1507, in raise_error
    raise e
  File "spacy\pipeline\trainable_pipe.pyx", line 75, in spacy.pipeline.trainable_pipe.TrainablePipe.pipe
  File "spacy\pipeline\tagger.pyx", line 111, in spacy.pipeline.tagger.Tagger.predict
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\thinc\model.py", line 315, in predict
    return self._func(self, X, is_train=False)[0]
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\thinc\layers\chain.py", line 54, in forward
    Y, inc_layer_grad = layer(X, is_train=is_train)
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\thinc\model.py", line 291, in __call__
    return self._func(self, X, is_train=is_train)
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\thinc\layers\chain.py", line 54, in forward
    Y, inc_layer_grad = layer(X, is_train=is_train)
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\thinc\model.py", line 291, in __call__
    return self._func(self, X, is_train=is_train)
  File "C:\.....\01_Prodigy\prodigy-1.11.1\venv\lib\site-packages\spacy_transformers\layers\trfs2arrays.py", line 23, in forward
    for trf_data in trf_datas:
TypeError: 'FullTransformerBatch' object is not iterable

I use:
spacy==3.1.1
spacy-transformers==1.0.4
prodigy==1.11.1

Thanks for the report! If you have the latest versions of spacy and spacy-transformers installed (which seems to be the case based on your details), this might be a spaCy bug that should have been fixed, but maybe still occurs in some situations :thinking: We'll look into it!

Hi! This should now be fixed after upgrading to spacy-transformers 1.0.5.

Hi @SofieVL ,

Yes, I just installed the spacy-transformers 1.0.5 and it works!

Thank you very much!

1 Like

Happy to hear it, thanks for reporting back!