calmiLovesAI / Basic_CNNs_TensorFlow2

A tensorflow2 implementation of some basic CNNs(MobileNetV1/V2/V3, EfficientNet, ResNeXt, InceptionV4, InceptionResNetV1/V2, SENet, SqueezeNet, DenseNet, ShuffleNetV2, ResNet).
MIT License
526 stars 178 forks source link

Assign different gradient weights #24

Open Cris-chen opened 3 years ago

Cris-chen commented 3 years ago

How to write the code to assign different gradient weights to different classes of SparseCategoricalCrossentropy

calmiLovesAI commented 2 years ago

The sample_weight param may work. https://tensorflow.google.cn/api_docs/python/tf/keras/losses/SparseCategoricalCrossentropy#__call__