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

Method flatten

monai/transforms/compose.py:492–506  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

490 return list(weights)
491
492 def flatten(self):
493 transforms = []
494 weights = []
495 for t, w in zip(self.transforms, self.weights):
496 # if nested, probability is the current weight multiplied by the nested weights,
497 # and so on recursively
498 if isinstance(t, OneOf):
499 tr = t.flatten()
500 for t_, w_ in zip(tr.transforms, tr.weights):
501 transforms.append(t_)
502 weights.append(w_ * w)
503 else:
504 transforms.append(t)
505 weights.append(w)
506 return OneOf(transforms, weights, self.map_items, self.unpack_items)
507
508 def __call__(self, data, start=0, end=None, threading=False, lazy: bool | None = None):
509 if start != 0:

Callers 15

test_len_and_flattenMethod · 0.95
logitsMethod · 0.45
decodeMethod · 0.45
__init__Method · 0.45
forwardMethod · 0.45
encode_forwardMethod · 0.45
decode_forwardMethod · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
forwardMethod · 0.45

Calls 2

OneOfClass · 0.85
appendMethod · 0.45

Tested by 8

test_len_and_flattenMethod · 0.76
test_revertMethod · 0.36
testMethod · 0.36
test_randomizeMethod · 0.36
test_zipdatasetMethod · 0.36
test_correctMethod · 0.36
test_correct_shapeMethod · 0.36
test_correctMethod · 0.36