'Tensorflow - keras - shapes and loss for multilabel classification
X_np_new.shape, y.shape
((50876, 2304), (50876, 9))
Code:
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, Activation
from tensorflow.keras.optimizers import SGD
model = Sequential()
model.add(Dense(5000, activation='relu', input_dim=X_np_new.shape[1]))
model.add(Dropout(0.1))
model.add(Dense(600, activation='relu'))
model.add(Dropout(0.1))
model.add(Dense(X_np_new.shape[1], activation='sigmoid'))
sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy',
optimizer=sgd)
model.fit(X_np_new, y, epochs=5, batch_size=2000)
preds = model.predict(X_np_new)
I get error:
ValueError: Shapes (None, 9) and (None, 2304) are incompatible
What went wrong here?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
