forked from tensorflow/similarity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove references to outputs in contrastive model. (tensorflow#311)
* Remove references to outputs in contrastive model. We use the inputs and outputs to support saving the contrastive model using the Keras API, however, we override train and test steps as well as predict. This means we don't currently support multiple output heads on the embedding output. This PR removes all references to multi-headed outputs and explicitly sets the indexer to use the predictor output. * Provide default contrastive projector and predictor. Users had to provide their own MLP models for the projector and predictor. This required understanding more about the underlying algorithms. This change now adds default projector and predictor models based on the original papers. * Update unsupervised colab. * Comment out projector and predictor create model functions. We now automatically create the MLP models for users, but the commented code is left in case the user wants to customize them. * Verify that the model trains and reloads. * Loss and performance is slightly better than before. * Update the create_contrastive_model function to pass a list of outputs to better track the outputs. The model still overrides the predict function though as we need to apply the L2 Norm at the output. * Fix mypy error. * Update ouput var name and use epsilon constant.
- Loading branch information
1 parent
c4a8675
commit 7d0f528
Showing
4 changed files
with
1,900 additions
and
307 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters