lukas / ml-class

Machine learning lessons and teaching projects designed for engineers
https://www.youtube.com/channel/UCBp3w4DCEC64FZr4k9ROxig
GNU General Public License v2.0
2.36k stars 1.17k forks source link

error in videos/seq2seq/train.py #74

Open alexandrovsky opened 2 years ago

alexandrovsky commented 2 years ago

Hi, when I run train.py, I get the following error:

Traceback (most recent call last): File "wandb-tutorials/ml-class/videos/seq2seq/train.py", line 131, in <module> guess = ctable.decode(preds[0], calc_argmax=False) File "wandb-tutorials/ml-class/videos/seq2seq/train.py", line 41, in decode return ''.join(self.indices_char[x] for x in x) File "wandb-tutorials/ml-class/videos/seq2seq/train.py", line 41, in <genexpr> return ''.join(self.indices_char[x] for x in x) TypeError: unhashable type: 'numpy.ndarray'

Any ideas how to fix this?

thisisvk45 commented 3 months ago

The error occurs because a numpy.ndarray is being used as an index, which isn't allowed. To fix it, flatten the array and convert it to a list of indices before decoding. Adjust the decode method to handle numpy.ndarray correctly.