I have been following a tutorial that shows how to make a word2vec
model.
This tutorial uses this piece of code:
similarity = merge([target, context], mode='cos', dot_axes=0)
(no other info was given, but I suppose this comes from keras.layers
)
Now, I've researched a bit on the merge
method but I couldn't find much about it.
From what I understand, it has been replaced by a lot of functions like layers.Add(), layers.Concat()...
.
What should I use? There's .Dot()
, which has an axis
parameter (which seems to be correct) but no mode
parameter.
What can I use in this case?
The Dot
layer in Keras now supports built-in Cosine similarity using the normalize = True
parameter.
From the Keras Docs:
keras.layers.Dot(axes, normalize=True)
normalize: Whether to L2-normalize samples along the dot product axis before taking the dot product. If set to True, then the output of the dot product is the cosine proximity between the two samples.
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With