Skip to content

Instantly share code, notes, and snippets.

@kgrm
Last active May 29, 2018 19:31
Show Gist options
  • Save kgrm/e0741af9fda6ee7b04871d10f6a1d811 to your computer and use it in GitHub Desktop.
Save kgrm/e0741af9fda6ee7b04871d10f6a1d811 to your computer and use it in GitHub Desktop.
from keras.layers import Input, Dense, Lambda
from keras.models import Model
def eucl_dist(inputs):
x, y = inputs
return ((x - y)**2).sum(axis=-1)
x = Input((32,))
y1 = Dense(8)(x)
y2 = Dense(8)(x)
y = Lambda(eucl_dist, output_shape=(1,))([y1, y2])
m = Model(x, y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment