A subclass of Algorithm implements a domain generalization algorithm. Subclasses should implement the following: - update() - predict()
| 53 | |
| 54 | |
| 55 | class 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 | |
| 81 | class ERM(Algorithm): |
nothing calls this directly
no outgoing calls
no test coverage detected