给定批量 RGB 图像作为输入,shape=(batch_size, width, height, 3)
多类目标表示为 one-hot,shape=(batch_size, width, height, n_classes)
以及最后一层具有 softmax 激活的模型(Unet、DeepLab)。
我正在寻找 kera/tensorflow 中的加权分类交叉熵损失函数。
class_weight
中的论点似乎fit_generator
不起作用,我在这里或https://github.com/keras-team/keras/issues/2115中没有找到答案。
def weighted_categorical_crossentropy(weights):
# weights = [0.9,0.05,0.04,0.01]
def wcce(y_true, y_pred):
# y_true, y_pred shape is (batch_size, width, height, n_classes)
loos = ?...
return loss
return wcce
Run Code Online (Sandbox Code Playgroud)