braintools.input.Transformed#
- class braintools.input.Transformed(input_obj, func)#
Custom transformation applied to an input.
Applies an arbitrary function to transform an input, enabling custom nonlinearities and processing.
- Parameters:
Examples
>>> import jax.numpy as jnp >>> sine = Sinusoidal(1.0, 10 * u.Hz, 200 * u.ms) >>> >>> # Half-wave rectification >>> rectified = Transformed(sine, lambda x: jnp.maximum(x, 0)) >>> >>> # Squaring (frequency doubling) >>> squared = Transformed(sine, lambda x: x ** 2) >>> >>> # Sigmoid nonlinearity >>> sigmoid = Transformed(sine, ... lambda x: 1 / (1 + jnp.exp(-10 * x))) >>> >>> # Usually created via apply() method >>> transformed = sine.apply(lambda x: jnp.abs(x))
Methods
__init__(input_obj, func)Initialize transformed input.
apply(func)Apply a custom function to the input.
clip([min_val, max_val])Clip the input values to a range.
generate()Generate the transformed input.
repeat(n_times)Repeat the input pattern n times.
scale(factor)Scale the input by a factor.
shift(time_shift)Shift the input in time.
smooth(tau)Apply exponential smoothing to the input.
Attributes
dtGet the time step from global environment.
n_stepsGet the number of time steps.
shapeGet the shape of the input array.