Error when executing trainer.train() in ungraded lab - 2 Question Answering with BERT and HuggingFace (Fine-tuning)


I came up with an error when executing trainer.train() in ungraded lab - 2Question Answering with BERT and HuggingFace (Fine-tuning).

TypeError Traceback (most recent call last)
in <cell line: 24>()
22 )
—> 24 trainer.train()

8 frames
/usr/local/lib/python3.10/dist-packages/tensorflow/python/framework/ in len(self)
336 “”“Returns the length of the first dimension in the Tensor.”“”
337 if not self.shape.ndims:
→ 338 raise TypeError(“Scalar tensor has no len()”)
339 # pylint: disable=protected-access
340 try:

TypeError: Scalar tensor has no len()

I have no idea what the problem is. I followed the instructions (executed all steps)

You have to specify more clearly which week is this lab located to?

Week 3

1 Like

Week 3

Any help with this?

Hello, I tried to find this lab but the names are different. My suggestion to you is that close and reopen the lab, unless something has been updated in some library. If you still facing the issue maybe @Mubsi can have a look at this. Thanks.

Hi @gent.spah & @Jorge_Mendoza,

Thanks for catching this @Jorge_Mendoza. The notebook got changed on our end unintentionally.

Everything should work now. Please try again and let me know.


1 Like

Thank you Mubsi.

What was wrong? (I’d like to understand as part of the learning process, if possible). Thank you again.

Nothing that should concern the learners.

Accidentally, while experimenting with the code of the notebook, some code was left in there which shouldn’t have been left behind.