Created
August 6, 2020 22:15
-
-
Save thunderInfy/4bacc0afff37e60a09539c76f8164520 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # zero out grads | |
| optimizer.zero_grad() | |
| # retrieve xq and xk the two image batches | |
| xq = sample_batched['image1'] | |
| xk = sample_batched['image2'] | |
| # move them to the device | |
| xq = xq.to(device) | |
| xk = xk.to(device) | |
| # get their outputs | |
| q = resnetq(xq) | |
| k = resnetk(xk) | |
| k = k.detach() | |
| # normalize the ouptuts, make them unit vectors | |
| q = torch.div(q,torch.norm(q,dim=1).reshape(-1,1)) | |
| k = torch.div(k,torch.norm(k,dim=1).reshape(-1,1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment