暹罗CNNTensorflow的激活功能是什么?

问题描述

我正在使用预先训练的VGG16网络训练暹罗CNN,并添加几层,然后计算相似度函数(两个图像特征之间的绝对距离)。 VGG16瓶颈后的模型如下:

left_input = Input(input_shape)
right_input = Input(input_shape)

model.add(Dense(1024,activation='relu')) 
model.add(BatchNormalization())
model.add(Dropout(0.30))
model.add(Dense(1024,activation='sigmoid')) 

encoded_l = model(left_input)
encoded_r = model(right_input)
    
L1_layer = Lambda(lambda tensors:K.abs(tensors[0] - tensors[1]))
L1_distance = L1_layer([encoded_l,encoded_r])
L1_distance = K.pow(L1_distance,3)

prediction = Dense(1,activation='sigmoid',bias_initializer=initialize_bias)(L1_distance)

siamese_net = Model(inputs=[left_input,right_input],outputs=prediction)

我本质上是在关注这篇文章:https://github.com/hlamba28/One-Shot-Learning-with-Siamese-Networks/blob/master/Siamese%20on%20Omniglot%20Dataset.ipynb

该模型在大量类中表现不佳。我想知道激活函数是否存在问题:对于两个相同的图像,L1_distance将为0,因此网络将必须训练一个无限的偏差以获得1的输出,这感觉不正确。

我已经搜索了TF激活函数,但找不到对称函数,该对称函数在0处本质上为1,在+/- Inf处本质上为0。我尝试了一个tf.math.reciprocal层的变通办法,但感觉不对(而且效果也不佳)。

我应该尝试编写自定义激活功能吗?有更好的方法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...