ReflectionPad1d

Contents

ReflectionPad1d#

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

Pads the input tensor using the reflection of the input boundary.

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)

  • 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.ReflectionPad1d(2)
>>> input = jnp.array([[[1, 2, 3, 4, 5]]])
>>> output = pad(input)
>>> print(output.shape)
(1, 9, 1)