def distance_layer(x1, x2):
"""Distance and angle of two inputs.
Compute the concatenation of element-wise subtraction and
multiplication of two inputs.
"""
def _distance(args):
x1 = args[0]
x2 = args[1]
x = K.abs(x1 - x2)
return x
def _multiply(args):
x1 = args[0]
x2 = args[1]
return x1 * x2
distance = Lambda(_distance, output_shape=(K.int_shape(x1)[-1],))([x1, x2])
multiply = Lambda(_multiply, output_shape=(K.int_shape(x1)[-1],))([x1, x2])
return concatenate([distance, multiply])
评论列表
文章目录