Keras损失函数,使用哪个?

时间:2019-02-04 18:09:36

标签: python tensorflow keras deep-learning

我正在实现深度学习问题的Keras版本,其中我需要检测车道,即定义给定道路上的车道的白色油漆。为此,我生成了“ logit”作为我创建的解码器模型的输出,

#Decoder 
score_5 =  Conv2D(64, kernel_size = (1, 1), strides = (1,1), padding='same', use_bias = False)(max_pool5)

deconv = Conv2DTranspose(64, kernel_size = (4,4), strides=(2,2), use_bias = False)(score_5)
score_4 = Conv2D(64, kernel_size = (1, 1), strides = (1,1), padding='same', use_bias = False)(max_pool4)
fused = keras.layers.Add()([score_4, deconv])
deconv = Conv2DTranspose(64, kernel_size = (4,4), strides=(2,2), use_bias = False)(fused)
score_3 = Conv2D(64, kernel_size = (1, 1), strides = (1,1), padding='same', use_bias = False)(max_pool3)
fused = keras.layers.Add()([score_3, deconv])

deconv_final = Conv2DTranspose(64, kernel_size = (16,16), strides=(8,8), use_bias = False)(fused)

score_final = Conv2D(2, kernel_size = (1, 1), strides = (1,1), padding='same', use_bias = False)(deconv_final)

现在,我想使用Keras compile(optimizer, loss=None, metrics=None, loss_weights=None, sample_weight_mode=None, weighted_metrics=None, target_tensors=None)中的model.compile API函数编译模型以拟合数据,并希望使用与以下张量流损失函数等效的Keras等效项。

binary_segmenatation_loss = tf.losses.sparse_softmax_cross_entropy(
            labels= binary_label, logits= score_final, weights=inverse_weights)

其中的标签是地面真相二进制数据,泳道为白色,其余图像像素为黑色,但是我不确定如何在Keras中使用相同的数据,即logit损失?

0 个答案:

没有答案