im making a neural network called EDITH and when i compile it, it works, here is the code for the neural network data creator:
words = [lemmatizer.lemmatize(word) for word in words if word not in ignore_letters]
words = sorted(set(words))
classes = sorted(set(classes))
pickle.dump(words, open('words.pkl', 'wb'))
pickle.dump(classes, open('classes.pkl', 'wb'))
traning = []
output_empty = [0] * len(classes)
for document in documents:
bag = []
word_patterns = document[0]
word_patterns = [lemmatizer.lemmatize(word.lower()) for word in word_patterns]
for word in words:
bag.append(1) if word in word_patterns else bag.append(0)
output_row = list(output_empty)
output_row[classes.index(document[1])] = 1
traning.append([bag, output_row])
random.shuffle(traning)
traning = np.array(traning)
tx = list(traning[:, 0])
ty = list(traning[:, 1])
model = Sequential()
model.add(Dense(128, input_shape=(len(tx[0]),), activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(len(ty[0]), activation='softmax'))
sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
hist = model.fit(np.array(tx), np.array(ty), epochs=10000, batch_size=5, verbose=1)
model.save('edith.h5', hist)
print("Done")
And the run program to use the data compiled by the code above, it gives me this error:
ValueError: Exception encountered when calling layer "sequential" (type Sequential).
Input 0 of layer "dense" is incompatible with the layer: expected axis -1of input shape to have value 11, but received input with shape (None, 1)
Call arguments received:
• inputs=tf.Tensor(shape=(None, 1), dtype=int32)
• training=False
• mask=None