Input module

The Input module defines the interface between the model and the data.

Each input:

  • Has a unique name and defined dimensionality

  • Can be associated with a temporal context window

  • Can access past and/or future samples

Inputs may originate from external datasets or from internal connections to other model components. This flexibility enables complex signal routing and the construction of composite model architectures.

class nnodely.layers.input.Input(name: str, *, dimensions: int = 1)[source]

Represents an Input in the neural network model.

Parameters:
  • json_name (str) – The name of the JSON field to store the Input configuration.

  • name (str) – The name of the Input.

  • dimensions (int, optional) – The number of dimensions for the input. Default is 1.

json_name

The name of the JSON field to store the input configuration.

Type:

str

name

The name of the Input.

Type:

str

dim

A dictionary containing the dimensions of the Input.

Type:

dict

json

A dictionary containing the configuration of the Input.

Type:

dict

classmethod clearNames(names: str | list | None = None)
closedLoop(obj: Stream) Input[source]

Update and return the current Input in a closed loop with a given Stream object.

Parameters:

obj (Stream) – The Stream object for update the Input.

Returns:

A Input with the connection to the obj Stream

Return type:

Input

Raises:
  • TypeError – If the provided object is not of type Input.

  • KeyError – If the Input variable is already connected.

connect(obj: Stream) Input[source]

Update and return the current Input with a given Stream object.

Parameters:

obj (Stream) – The Stream object for update the Input.

Returns:

A Input with the connection to the obj Stream

Return type:

Input

Raises:
  • TypeError – If the provided object is not of type Input.

  • KeyError – If the Input variable is already connected.

last() Stream[source]

Selects the last passed instant for the input.

Returns:

A Stream representing the SamplePart object with the last passed instant.

Return type:

Stream

names = ['SampleTime']
next() Stream[source]

Selects the next instant for the input.

Returns:

A Stream representing the SamplePart object with the next instant.

Return type:

Stream

s(order: int, *, der_name: str | None = None, int_name: str | None = None, method: str = 'euler') Stream[source]

Considering the Laplace transform notation. The function is used to operate an integral or derivate operation on the input. The order of the integral or the derivative operation is indicated by the order parameter.

Parameters:
  • order (int) – Order of the Laplace transform

  • method (str, optional) – Integration or derivation method

Returns:

A Stream of the signal represents the integral or derivation operation.

Return type:

Stream

sw(sw: int | list, offset: int | None = None) Stream[source]

Selects a sample window for the Input.

Parameters:
  • sw (list, int) – The sample window. If a list, it should contain the start and end indices. If an int, it represents the number of steps in the past.

  • offset (int, optional) – The offset for the sample window. Default is None.

Returns:

A Stream representing the SamplePart object with the selected samples.

Return type:

Stream

Raises:

TypeError – If the sample window is not an integer or a list of integers.

Example

Select a sample window considering a signal:

T = [-3,-2,-1,0,1,2]

where time 0 is the last passed instant.

T.sw(2)        # [-1, 0]
T.sw([-2,0])   # [-1, 0]
T.sw([0,1])    # [1]
T.sw([-4,-2])  # [-3,-2]

With offset:

T.sw(2, offset=-2)      # [0, 1]
T.sw([-2,2], offset=-1)
tw(tw: int | float | list, offset: int | float | None = None) Stream[source]

Selects a time window for the Input.

Parameters:
  • tw (list or float) – The time window. If a list, it should contain the start and end values. If a float, it represents the time window size.

  • offset (float, optional) – The offset for the time window. Default is None.

Returns:

A Stream representing the TimePart object with the selected time window.

Return type:

Stream

Raises:
  • ValueError – If the time window is not positive.

  • IndexError – If the offset is not within the time window.

z(delay: int) Stream[source]

Considering the Zeta transform notation. The function is used to selects a unitary delay from the Input.

Parameters:

delay (int) – The delay value.

Returns:

A Stream representing the SamplePart object with the selected delay.

Return type:

Stream

Examples

Select the unitary delay considering a signal:

T = [-3, -2, -1, 0, 1, 2]

where the time vector 0 represents the last passed instant.

T.z(-1)  # = 1
T.z(0)   # = 0  # the last passed instant
T.z(2)   # = -2