Tokenize_labels() function in assignment?

I need help with 'substract 1 from every value of the labels '.

I have tried:

np.subtract(np.array(split_labels), np.ones(len(split_labels)))

and np.array(split_labels) -1.

thank you.

2 Likes

Hey bluetail!

So it looks like you’re trying to act on the labels themselves, before they’ve been converted to sequences.

You might want to pay close attention to the instructions in this code block, and make sure you’ve completed all previous instructions!

Hope that helps and keep up the good work! :smiley:

Chris

1 Like

I’m afraid I’m still stuck. my output is not the same as expected.

label_seq_np = np.array(label_seq, dtype = int) -1

Glad you were able to address the issue!

Hope I was able to help!

Have an awesome day,
Chris

label_tokenizer.fit_on_texts() , use all_labels
label_tokenizer.texts_to_sequences(), use split_labels

I hope it can help you. Thank you

6 Likes

I have same issue, has that been answered?


please help me here

Is it still a problem? When I did np.array( label_seq ) - 1 it worked for me. I did some search though & some forums seems to suggest it could be a numpy version issue. You could try doing
!pip install numpy==1.21.1

I happen to read this thread since I missed to do -1 on the labels & was not getting values match, since Tokenizer() reserves the 0 index. (I reported it as an issue, before I realized it :shushing_face:)

I think we should not be required to mandatorily tokenize the labels. Purpose seems to be to map these Categorical Values to a range [0,4] so that we can match the output of softmax in output layer. So you may as well write a mapper for labels → values [0,1,2,3,4] & would be fine.

Tutors please correct me if wrong.