Keras Level Merge Warning

I keep getting this warning:

lstm.py:119: UserWarning: the function is mergedeprecated and will be removed after 08/2017. Use layers from keras.layers.merge, for example, instead . add, concatenateetc. merged_vector = merge ([l1, l2], mode = lambda x: (x [0] - x [1]) ** 2, output_shape = lambda x: x [0]) / Library / Python / 2.7 / site-packages /keras/legacy/layers.py:456: UserWarning: The level is mergeoutdated and will be removed after 08/2017. Use layers from keras.layers.merge, for example, instead . add, concatenateetc. Name = Name)

Which is related to the following line of code:

merged_vector = merge([l1, l2], mode=lambda x: (x[0] - x[1])**2, output_shape=lambda x: x[0])

My model works fine, but how do I implement custom merging in Keras 2.0.2? Thank.

+4
source share
1 answer

Answering my own question:

# Custom Merge
def euclid_dist(v):
    return (v[0] - v[1])**2

def out_shape(shapes):
    return shapes[0]

merged_vector = Lambda(euclid_dist, output_shape=out_shape)([l1, l2])
+5
source

Source: https://habr.com/ru/post/1673782/


All Articles