我试图找出是否有任何方法可以在Keras中实现L2池化层。有谁知道如何处理它?</ p>
答案 0 :(得分:0)
在this答案的基础上,我在此处的评论中提到的是您要查找的L2-norm池化层。
from keras.layers import Lambda
import keras.backend as K
def l2_norm2d(x, pool_size = (2,2), strides = None,
padding = 'valid', data_format=None):
if strides is None:
strides = pool_size
x = x ** 2
output = K.pool2d(x, pool_size, strides,
padding, data_format, pool_mode='avg')
output = K.sqrt(output)
return output