Triplet loss on text embeddings with keras

≡放荡痞女 提交于 2019-12-11 16:08:28

问题


I'd start saying i'm quite new to Keras and machine learning in general. I'm trying to build an "experimental" model consisting of two parts:

  1. An "encoder" which takes a string (containing a long series of attributes, i'm using the DBLP-ACM dataset), builds an embedding of the words of this string (word2vec), and encodes them in a vector (bidirectional LSTM).
  2. A trainable model which takes 3 vectors in input (result of model 1) and uses the triplet loss as loss function (i already defined it, using the euclidean distance between the vectors)

My first step was adapting this model to my dataset, then i created a triplets dataset and i defined the triplet loss function, as i said earlier. I'm now trying to figure out how can i modify this model to accept 3 inputs, distinguishing step 1 and step 2, and applying the proper loss function.

It's quite tricky, but i'm sure is easier than i think. I can provide my actual model, but it's quite similar to the one i linked above (which should represent the first step), except for the input format. Every advice, idea or code snippet is well appreciated!

来源:https://stackoverflow.com/questions/56951787/triplet-loss-on-text-embeddings-with-keras

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!