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 x = paddle.rand([1, 2, 3, 4]) # [[[[0.5002636 0.22272532 0.17402348 0.2874594 ] # [0.95313174 0.6228939 0.7129065 0.7087491 ] # [0.02879342 0.88725346 0.61093384 0.38833922]] # [[0.5231306 0.03807496 0.91661984 0.15602879] # [0.666127 0.616567 0.30741522 0.24044901] # [0.7142536 0.7351477 0.31588817 0.23782359]]]] m = paddle.nn.Maxout(groups=2) out = m(x) # [[[[0.5231306 0.22272532 0.91661984 0.2874594 ] # [0.95313174 0.6228939 0.7129065 0.7087491 ] # [0.7142536 0.88725346 0.61093384 0.38833922]]]]
-
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.