我是 DL 的新手,当我适合我的模型时,我遇到了这个错误
ValueError: Shapes (3, 1) and (4, 3) are incompatible
数据集:
Features: [0.22222222 0.625 0.06779661 0.04166667], Target: [1 0 0]
Features: [0.16666667 0.41666667 0.06779661 0.04166667], Target: [1 0 0]
Features: [0.11111111 0.5 0.05084746 0.04166667], Target: [1 0 0]
Features: [0.08333333 0.45833333 0.08474576 0.04166667], Target: [1 0 0]
Features: [0.19444444 0.66666667 0.06779661 0.04166667], Target: [1 0 0]
模型:
def build_fc_model():
fc_model = tf.keras.Sequential([
tf.keras.layers.Dense(4, activation=tf.nn.softmax),
tf.keras.layers.Dense(4, activation=tf.nn.softmax),
tf.keras.layers.Dense(3, activation=tf.nn.softmax),
])
return fc_model```
model.fit 错误
model = build_fc_model()
model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=1e-1), loss='categorical_crossentropy', metrics=['accuracy'])
BATCH_SIZE = 10
EPOCHS = 5
model.fit(dataset, batch_size=BATCH_SIZE, epochs=EPOCHS)
谢谢你的帮助
阿波罗的战车
相关分类