Compose¶

class Compose(transforms=[], batch_compose=False, shuffle_indices=None, *, order=None)[源代码]

>>> import megengine.data.transform as T
>>> T.Compose([
...     T.RandomHorizontalFlip(),  # 1st
...     T.RandomVerticalFlip(),    # 2nd
...     T.CenterCrop(100),         # 3rd
...     T.ToMode("CHW"),           # 4th
...     ],
...     shuffle_indices=[(1, 2, 3)]
... )


$\begin{split}\begin{array}{cc} [{\color{red}1 \quad 2 \quad 3} \quad 4] & [{\color{red}1 \quad 3 \quad 2} \quad 4] \\ [{\color{red}2 \quad 1 \quad 3} \quad 4] & [{\color{red}2 \quad 3 \quad 1} \quad 4] \\ [{\color{red}3 \quad 1 \quad 2} \quad 4] & [{\color{red}3 \quad 2 \quad 1} \quad 4] \end{array}\end{split}$

$\begin{split}\begin{array}{cc} [{\color{red}1} \quad {\color{blue}2} \quad {\color{red}3} \quad {\color{blue}4}] & [{\color{red}1} \quad {\color{blue}4} \quad {\color{red}3} \quad {\color{blue}2}] \\ [{\color{red}3} \quad {\color{blue}2} \quad {\color{red}1} \quad {\color{blue}4}] & [{\color{red}3} \quad {\color{blue}4} \quad {\color{red}1} \quad {\color{blue}2}] \end{array}\end{split}$

apply(input)[源代码]

apply_batch(inputs)[源代码]