MCPcopy Create free account
hub / github.com/alexrame/fishr / update

Method update

domainbed/algorithms.py:100–109  ·  view source on GitHub ↗
(self, minibatches, unlabeled=None)

Source from the content-addressed store, hash-verified

98 )
99
100 def update(self, minibatches, unlabeled=None):
101 all_x = torch.cat([x for x, y in minibatches])
102 all_y = torch.cat([y for x, y in minibatches])
103 loss = F.cross_entropy(self.predict(all_x), all_y)
104
105 self.optimizer.zero_grad()
106 loss.backward()
107 self.optimizer.step()
108
109 return {'loss': loss.item()}
110
111 def predict(self, x):
112 return self.network(x)

Callers

nothing calls this directly

Calls 1

predictMethod · 0.95

Tested by

no test coverage detected