InvalidArgumentError: logits and labels must have the same first dimension

雪域幽狐 2021-03-02 14:51 阅读:5512


InvalidArgumentError:  logits and labels must have the same first dimension, got logits shape [20,2] and labels shape [40]
一个可能的处理方式是
model.compile(optimizer='adam',
              loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
              metrics=['accuracy'])
修改SparseCategoricalCrossentropy为CategoricalCrossentropy

0条评论

登陆后可评论