MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / test_cutmixd

Method test_cutmixd

tests/transforms/test_regularization.py:86–96  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

84 self.assertTrue(any(not torch.allclose(sample, cutmix(sample)) for _ in range(10)))
85
86 def test_cutmixd(self):
87 for dims in [2, 3]:
88 shape = (6, 3) + (32,) * dims
89 t = torch.rand(*shape, dtype=torch.float32)
90 label = torch.randint(0, 1, shape)
91 sample = {"a": t, "b": t, "lbl1": label, "lbl2": label}
92 cutmix = CutMixd(["a", "b"], 6, label_keys=("lbl1", "lbl2"))
93 cutmix.set_random_state(seed=123)
94 output = cutmix(sample)
95 # but mixing of labels is not affected by it
96 self.assertTrue(torch.allclose(output["lbl1"], output["lbl2"]))
97
98
99class TestCutOut(unittest.TestCase):

Callers

nothing calls this directly

Calls 2

set_random_stateMethod · 0.95
CutMixdClass · 0.90

Tested by

no test coverage detected