InvalidArgumentError: Received A Label Value Of 8825 Which Is Outside The Valid Range Of [0, 8825) SEQ2SEQ Model
I have been trying to build RNN with Seq2Seq model from Udemy course called DeepLearning_NLP_Chatbot, and I followed him step by step, but I face when training an error: InvalidArg
Solution 1:
In the last layer for eg you used model.add(Dense(1, activation='softmax')). Here 1 restricts its value from [0, 1) change its shape to the maximum output label. For eg your output is from label [0,7) then use model.add(Dense(7, activation='softmax'))
input_text = Input(shape=(max_len,), dtype=tf.string)
embedding = Lambda(ElmoEmbedding, output_shape=(max_len, 1024))(input_text)
x = Bidirectional(LSTM(units=512, return_sequences=True,
recurrent_dropout=0.2, dropout=0.2))(embedding)
x_rnn = Bidirectional(LSTM(units=512, return_sequences=True,
recurrent_dropout=0.2, dropout=0.2))(x)
x = add([x, x_rnn]) # residual connection to the first biLSTM
out = TimeDistributed(Dense(n_tags, activation="softmax"))(x)
Here in TimeDistributed layer n_tags is the length of tags from which I want to classify.
If I predict some other quantity such as q_tag whose length is different from n_tags i.e suppose 10 and length of n_tags is 7 and I received 8 as output label it will give the invalid argument error Received a label value of 8 which is outside the valid range of [0, 7).
Post a Comment for "InvalidArgumentError: Received A Label Value Of 8825 Which Is Outside The Valid Range Of [0, 8825) SEQ2SEQ Model"