class oneflow.nn.ConstantPad1d(padding: Union[int, tuple, list], value: Union[int, float] = 0)

Pads the input tensor boundaries with a constant value. The interface is consistent with PyTorch, and referenced from: https://pytorch.org/docs/1.10/generated/torch.nn.ConstantPad1d.html.

For N-dimensional padding, use torch.nn.functional.pad().

Parameters
• padding (int, list, tuple) – the size of the padding. If is int, uses the same padding in both boundaries. If a 2-tuple, uses ($$\text{padding_left}$$, $$\text{padding_right}$$)

• value (int, float) – The constant value used for padding. Defaults to 0.

Shape:
• Input: $$(N, C, W_{in})$$

• Output: $$(N, C, W_{out})$$ where

$$W_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}$$

For example:

>>> import oneflow as flow
>>> import numpy as np

>>> input = flow.tensor(np.arange(8).reshape(2,2,2).astype(np.float32))
>>> output = m(input)
>>> output
tensor([[[9.9999, 0.0000, 1.0000, 9.9999, 9.9999],
[9.9999, 2.0000, 3.0000, 9.9999, 9.9999]],

[[9.9999, 4.0000, 5.0000, 9.9999, 9.9999],
[9.9999, 6.0000, 7.0000, 9.9999, 9.9999]]], dtype=oneflow.float32)

__init__(padding: Union[int, tuple, list], value: Union[int, float] = 0)

Initialize self. See help(type(self)) for accurate signature.

Methods

 __call__(*args, **kwargs) Call self as a function. __delattr__(name, /) Implement delattr(self, name). __dir__() Default dir() implementation. __eq__(value, /) Return self==value. __format__(format_spec, /) Default object formatter. __ge__(value, /) Return self>=value. __getattr__(name) __getattribute__(name, /) Return getattr(self, name). __gt__(value, /) Return self>value. __hash__() Return hash(self). __init__(padding[, value]) Initialize self. __init_subclass__ This method is called when a class is subclassed. __le__(value, /) Return self<=value. __lt__(value, /) Return self