pyaj
November 1, 2021, 12:06pm
1
Hi, I have encountered this error while fitting my model.
ValueError: Failed to find data adapter that can handle input: <class ‘numpy.ndarray’>, (<class ‘list’> containing values of types {’(<class ‘list’> containing values of types {"<class ‘int’>"})’})
Exercise_2_BBC_news_archive_Question-FINAL.ipynb (26.9 KB)
Hi @pyaj ,
it’s difficult to understand what’s the problem. Can you send your python file?
pyaj
November 1, 2021, 1:16pm
3
Alright. should I copy all my codes here ?
You should send it as attachment
pyaj
November 1, 2021, 2:04pm
5
On this platform? How to do that?
When you reply, search for this symbol and attach:
pyaj
November 1, 2021, 2:29pm
7
Alright I have just uploaded the notebook
pyaj
November 1, 2021, 2:55pm
9
It’s in the initial question, at the top
In the last layer, the activation function you’re using is a sigmoid. But here you’re choosing between 6 units, not between 2. Change the activation accordingly and it should work.
Best,
Maurizio
pyaj
November 1, 2021, 3:19pm
11
I chose 2 instead of 6 dense units and I still get the same error. The exercise also recommends that we use 6 units of dense layer
You should change the activation function, not the number of units. Sigmoid is not the right one.
pyaj
November 1, 2021, 3:40pm
13
Oh I just checked again, it also shows the same error with the softmax activation
Sorry, I noticed just now: you should also change your target in the model.fit, where I see
train_labels (wrong)
PS: you should find an array that has values between 0 and 5
1 Like
pyaj
November 1, 2021, 5:22pm
15
I should have added the training_label_seq
pyaj
November 1, 2021, 5:40pm
16
@maurizioscibilia I am unfortunately back again. Please check this issue with me.
It seems like your sentences variable doesn’t show the text it was showing before. Can you send me the screenshot of what appears now, after you execute: sentences[0]
?
in cell [4] I can see that you have:
sentence = sentence.replace(" ", " ")
Try to remove it
1 Like
pyaj
November 2, 2021, 6:38am
20
It’s good now! Please check 3rd assignment’s question on this link
sentences=[]
labels=[]
random.shuffle(corpus)
for x in range(training_size):
sentences.append(corpus[x][0])
labels.append(corpus[x][1])
tokenizer = Tokenizer()
tokenizer.fit_on_texts(sentences)
word_index = tokenizer.word_index
vocab_size=len(word_index)
sequences = tokenizer.texts_to_sequences(sentences)
padded = pad_sequences(sequences, maxlen=max_length, padding=padding_type, truncating=trunc_type)
split = int(test_portion * training_size)
test_sequences = padded[:split]
trainin…