ConstantPad1d

Contents

ConstantPad1d#

class brainstate.nn.ConstantPad1d(padding, value=0, in_size=None, name=None)[source]#

Pads the input tensor with a constant value.

Parameters:
  • padding (int | Sequence[int]) –

    The size of the padding. Can be:

    • int: same padding for both sides

    • Sequence[int] of length 2: (left, right)

  • value (float) – The constant value to use for padding. Default is 0.

  • in_size (int | Sequence[int] | integer | Sequence[integer] | None) – The input size.

  • name (str | None) – The name of the module.

Examples

>>> import brainstate as brainstate
>>> import jax.numpy as jnp
>>> pad = brainstate.nn.ConstantPad1d(2, value=3.5)
>>> input = jnp.array([[[1, 2, 3, 4, 5]]])
>>> output = pad(input)
>>> print(output.shape)
(1, 9, 1)