sparsecatgoricalcrossentropy专题

AttributeError: module ‘tensorflow.keras.losses‘ has no attribute ‘SparseCatgoricalCrossentropy的解决方案

报错: 解决方案: 将model.compile里面的loss参数修改如下即可: model.compile(optimizer='adam', loss=tf.keras.SparseCaticalCrossentropy(from_logits=True), metrics=['accuracy']) 改为: model.compile(optimizer='adam',