Skip to content

Commit

Permalink
meta-SR
Browse files Browse the repository at this point in the history
  • Loading branch information
seongmin-kye committed Sep 16, 2020
1 parent b5434cb commit b4c1ea1
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 76 deletions.
158 changes: 84 additions & 74 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions losses/prototypical.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Prototypical(nn.Module):
def __init__(self):
super(Prototypical, self).__init__()

self.zero = torch.tensor(0).cuda()
self.criterion = torch.nn.CrossEntropyLoss()
print('Initialized Prototypical Loss')

Expand All @@ -22,8 +23,8 @@ def forward(self, support, query, label_g, label_e, model, use_GC=True):
loss_e = self.criterion(logit_e, label_e)
acc_e = self.accuracy(logit_e, label_e)

loss_g = 0
acc_g = 0
loss_g = self.zero
acc_g = self.zero
if use_GC:
inputs = torch.cat((support, query), dim=0)
logit_g = F.linear(inputs, F.normalize(model.weight))
Expand Down

0 comments on commit b4c1ea1

Please sign in to comment.