Tokenize_labels() np.array

So I can’t seem to do a np.array subtraction for val_label_seq = tokenize_labels(labels, val_labels)
although the function run smoothly on train_label_seq = tokenize_labels(labels, train_labels), it says that TypeError: unsupported operand type(s) for -: 'list' and 'int' when trying to subtract the np.array with 1 eventhough I made sure that I am subtracting np.array and not list.

Does anyone encountered the same issue or know the fix to this?

Please use np.asarray to convert a list to a numpy array before performing subtraaction.

I used np.asarray() and i still got the same issue

Please ensure that labels are of numeric type. Here’s an example:

>>> import numpy as np
>>> a = np.asarray(['1', '2', '0', '1'])
>>> a.dtype
>>> b = np.asarray([1, 2, 0, 1])
>>> b.dtype
1 Like