This is my code:
X_train, Y_train, X_test, Y_test = load_data(DATA_PATH)
model = keras.Sequential([
# input layer
# 1st dense layer
keras.layers.Dense(256, activation='relu', input_shape=(X_train.shape[1], X_train.shape[2], X_train.shape[3])),
# 2nd dense layer
keras.layers.Dense(128, activation='relu'),
# 3rd dense layer
keras.layers.Dense(64, activation='relu'),
# output layer
keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam',loss='categorical_crossentropy',metrics=['accuracy'])
model.summary()
classifier = model.fit(X_train,
Y_train,
epochs=100,
batch_size=128)
Y_train ,X_train
and Y_test ,X_test
are numpy arrays. X_train
contains 800 and X_test
200 .png pictures of size 128X128.
Y_train
contains 800 labels (80x1, 80x2, etc.) and Y_test
contains testing target (20x1, 20x2, etc.).
When I try to run this program I get the following error:
ValueError: Shapes (None, 1) and (None, 128, 128, 10) are incompatible
question from:
https://stackoverflow.com/questions/65902112/tensorflow-neural-network-does-not-work-incompatible-types 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…