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

Class Algorithm

domainbed/algorithms.py:55–78  ·  view source on GitHub ↗

A subclass of Algorithm implements a domain generalization algorithm. Subclasses should implement the following: - update() - predict()

Source from the content-addressed store, hash-verified

53
54
55class Algorithm(torch.nn.Module):
56 """
57 A subclass of Algorithm implements a domain generalization algorithm.
58 Subclasses should implement the following:
59 - update()
60 - predict()
61 """
62
63 def __init__(self, input_shape, num_classes, num_domains, hparams):
64 super(Algorithm, self).__init__()
65 self.hparams = hparams
66
67 def update(self, minibatches, unlabeled=None):
68 """
69 Perform one update step, given a list of (x, y) tuples for all
70 environments.
71
72 Admits an optional list of unlabeled minibatches from the test domains,
73 when task is domain_adaptation.
74 """
75 raise NotImplementedError
76
77 def predict(self, x):
78 raise NotImplementedError
79
80
81class ERM(Algorithm):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected