mindspore.mint.nn.ReflectionPad3d
- class mindspore.mint.nn.ReflectionPad3d(padding)[源代码]
使用输入边界的反射,对输入 input 的最后三维进行填充。
更多参考详见
mindspore.mint.nn.functional.pad()。警告
这是一个实验性API,后续可能修改或删除。
- 参数:
padding (Union[int, tuple, list]) - 指定填充的大小。
如果为int,则对所有边界进行相同大小的填充。
如果为tuple或list,则顺序为 \((\text{padding_left}, \text{padding_right}, \text{padding_top}, \text{padding_bottom}, \text{padding_front}, \text{padding_back})\)。
- 输入:
input (Tensor) - 输入tensor,shape为 \((C, D_{in}, H_{in}, W_{in})\) 或 \((N, C, D_{in}, H_{in}, W_{in})\)。
- 输出:
Tensor,填充后的tensor,shape为 \((C, D_{out}, H_{out}, W_{out})\) 或 \((N, C, D_{out}, H_{out}, W_{out})\) ,其中
\(D_{out} = D_{in} + \text{padding_front} + \text{padding_back}\)
\(H_{out} = H_{in} + \text{padding_top} + \text{padding_bottom}\)
\(W_{out} = W_{in} + \text{padding_left} + \text{padding_right}\)
- 支持平台:
Ascend
样例:
>>> import mindspore >>> arr = mindspore.mint.arange(8).astype(mindspore.float32).reshape((1, 2, 2, 2)) >>> x = mindspore.tensor(arr) >>> padding = (1, 1, 1, 0, 0, 1) >>> pad3d = mindspore.mint.nn.ReflectionPad3d(padding) >>> out = pad3d(x) >>> print(out) [[[[3. 2. 3. 2.] [1. 0. 1. 0.] [3. 2. 3. 2.]] [[7. 6. 7. 6.] [5. 4. 5. 4.] [7. 6. 7. 6.]] [[3. 2. 3. 2.] [1. 0. 1. 0.] [3. 2. 3. 2.]]]]