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

Method update

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

Source from the content-addressed store, hash-verified

150 return meta_weights
151
152 def update(self, minibatches, unlabeled=None):
153 self.create_clone(minibatches[0][0].device)
154
155 for x, y in minibatches:
156 loss = F.cross_entropy(self.network_inner(x), y)
157 self.optimizer_inner.zero_grad()
158 loss.backward()
159 self.optimizer_inner.step()
160
161 self.optimizer_inner_state = self.optimizer_inner.state_dict()
162 meta_weights = self.fish(
163 meta_weights=self.network.state_dict(),
164 inner_weights=self.network_inner.state_dict(),
165 lr_meta=self.hparams["meta_lr"]
166 )
167 self.network.reset_weights(meta_weights)
168
169 return {'loss': loss.item()}
170
171 def predict(self, x):
172 return self.network(x)

Callers

nothing calls this directly

Calls 3

create_cloneMethod · 0.95
fishMethod · 0.95
reset_weightsMethod · 0.80

Tested by

no test coverage detected