问题
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:
- 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).
- 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