Closed heet2201 closed 4 years ago
You should be using EmbeddingNet with OnlineTripletLoss, not TripletNet. See some examples in the notebooks.
Hi @adambielski, sorry for reviving a dead issue but I was wondering if you could explain a bit more why we use EmbeddingNet rather than TripletNet when using OnlineTripletLoss? I ran into the same issue as @heet2201 whereby I used a TripletNet and received the same error before going back to the example notebook and realising my mistake. However, looking through the code I can't seem to find the explanation as to why EmbeddingNet is used rather than TripletNet when using OnlineTripletLoss and a Triplet selector, surely we should be using the predefined TripletNetwork here? Have I missed something obvious?
@Trotts In my implementation TripletNetwork takes a triplet as an input - an anchor, a positive and a negative and returns a triplet of embeddings in the same order; so we need to sample the triplets before feeding them to the network and then we can compute TripletLoss on those specific triplets. All that TripletNetwork does is running the EmbeddingNet for anchors, positive and negative inputs.
If we want to use OnlineTripletLoss, we do not sample the triplest before feeding them to the network, we simply get the embeddings for a batch of images (that's why we use EmbeddingNet that only takes one input and returns one output) and use their labels (in a triplet selector) to create triplets afterwards and compute the loss on the computed embeddings. Now we can use one embedding to compute the loss for multiple triplets.
@adambielski thank you for the swift response! That makes perfect sense, I forgot that images have to be embedded before triplets can be selected, in which case using the EmbeddingNet is obvious!
Hello, I am training on custom data using OnlineTripletLoss, But during loss calculation, I got the following error.
And all feature Functions are as below,
Can Anyone help with it !! Thank You.