Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement contrastive loss function. #5

Open
tlatkowski opened this issue Feb 26, 2018 · 4 comments
Open

Implement contrastive loss function. #5

tlatkowski opened this issue Feb 26, 2018 · 4 comments
Labels
enhancement New feature or request

Comments

@tlatkowski
Copy link
Owner

Implement contrastive loss function according to paper:
http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf

@tlatkowski tlatkowski added the enhancement New feature or request label Feb 26, 2018
@datistiquo
Copy link

datistiquo commented May 24, 2019

Isn't it already implemented? In layers.losses there is a contrastive loss function.

But I tried, but the loss is always 0. So, indeed it seems not working, although you can hand over the loss function a an argument?

What is actually the constrastive? Since there is also contrastive_lecun.

In your function contrastive you only hand over prediction. How is from this postive and negative examples generated?

I suppose this lecun_contrastive is similiar to triplet loss and to be a contrastive loss und need postive and negative examples.

@datistiquo
Copy link

Hey @tlatkowski . Do you have an idea how I can use the loss other than MSE loss functions? I suppose I need to change the data set reader?

@tlatkowski
Copy link
Owner Author

Hi @datistiquo
in current version of pipeline you have to modify code for the specific model, for example, for multihead model you have to modify the line where constructor from the base class is called:

BaseSiameseNet.__init__(self, max_sequence_len, vocabulary_size, main_cfg, model_cfg, mse)

just change mse to contrastive for example

you also need to import it from losses module.

In the next version i will make a change in pipeline so you will be able to change loss from the main config file.

@datistiquo
Copy link

datistiquo commented May 28, 2019

Hi @tlatkowski

I already tried this, but I get for the loss zero.

I think you also need to change the input dataset to get pairs for the postive and negative examples at least for the contrastive_lecun function?

Why should the data set structure work for the contrastive function at all? You just handover the predction as argument. I dont see any operation where the postive and negative samples are extracted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants