Maxout¶
- class paddle.nn. Maxout ( groups, axis=1, name=None ) [source]
-
Maxout Activation. Create a callable object of Maxout.
Assumed the input shape is (N, Ci, H, W). The output shape is (N, Co, H, W). Then Co = Ci/groups and the operator formula is as follows:
\[\begin{split}\begin{array}{l} &out_{si+j} = \max_{k} x_{gsi + sk + j} \\ &g = groups \\ &s = \frac{input.size}{num\_channels} \\ &0 \le i < \frac{num\_channels}{groups} \\ &0 \le j < s \\ &0 \le k < groups \end{array}\end{split}\]- Parameters
-
groups (int) – The groups number of maxout. groups specifies the index of channel dimension where maxout will be performed. This must be a factor of number of features. Default is 1.
axis (int, optional) – The axis along which to perform maxout calculations. It should be 1 when data format is NCHW, be -1 or 3 when data format is NHWC. If
axis
< 0, it works the same way as \(axis + D\) , where D is the dimensions ofx
. Default is 1.name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.
- Shape:
-
input: \((N, C_{in}, H_{in}, W_{in})\)
output: \((N, C_{out}, H_{out}, W_{out})\)
Examples
>>> import paddle >>> paddle.seed(100) >>> x = paddle.rand([1, 2, 3, 4]) >>> m = paddle.nn.Maxout(groups=2) >>> out = m(x) >>> print(out) Tensor(shape=[1, 1, 3, 4], dtype=float32, place=Place(cpu), stop_gradient=True, [[[[0.85139430, 0.95717543, 0.43864486, 0.51577556], [0.84765935, 0.45680618, 0.39412445, 0.72039396], [0.59444654, 0.78120756, 0.78364515, 0.90572405]]]])
-
forward
(
x
)
forward¶
-
Defines the computation performed at every call. Should be overridden by all subclasses.
- Parameters
-
*inputs (tuple) – unpacked tuple arguments
**kwargs (dict) – unpacked dict arguments
-
extra_repr
(
)
extra_repr¶
-
Extra representation of this layer, you can have custom implementation of your own layer.