{Using Keras’ Tokenizer yields values that start at 1 rather than at 0. This will present a problem when training since Keras usually expects the labels to start at 0. To work around this issue you could use an extra neuron in the last layer of your model. However this approach is rather hacky and not very clear. Instead you will substract 1 from every value of the labels that the function returns. Remember that when using numpy arrays you can simply do something like np.array - 1
to accomplish this since numpy allows for vectorized operations.}
I’m Getting error: TypeError: unsupported operand type(s) for -: ‘list’ and ‘int’
Method i’m implementing,
Convert labels to sequences
label_seq = tokenizer.texts_to_sequences(split_labels)
Convert sequences to a numpy array. Don’t forget to substact 1 from every entry in the array!
label_seq_np = np.asarray(label_seq)-1