Skip to content

SimpleReservoir

svetlanna.networks.SimpleReservoir

SimpleReservoir(
    nonlinear_element: LinearOpticalSetupLike,
    delay_element: LinearOpticalSetupLike,
    feedback_gain: float,
    input_gain: float,
    delay: int,
)

Bases: Module

Reservoir network. The main idea is explained in the work. The governing formula is: $$ x_\text{out}[i] = F_\text{NL}(\beta x_\text{in}[i] + \alpha F_\text{D}(x_\text{out}[i-\tau])) $$ where \(F_\text{NL}\) is the nonlinear element, \(F_\text{D}\) is the delay element, \(\alpha\) is the feedback_gain, \(\beta\) is the input_gain, \(\tau\) is the delay in samples. The user should match the delay in samples with the actual light propagation time in \(F_\text{D}\).

Parameters:

  • nonlinear_element (LinearOpticalSetupLike) –

    The nonlinear element the light passes through.

  • delay_element (LinearOpticalSetupLike) –

    The delay line element.

  • feedback_gain (float) –

    The feedback (delay line) gain \(\alpha\).

  • input_gain (float) –

    The input gain \(\beta\)

  • delay (int) –

    The delay time, measured in samples, that the light spends in the delay line.

Examples:

import svetlanna as sv
from svetlanna.visualization import show_structure

sim_params = ...

reservoir = SimpleReservoir(
    nonlinear_element=sv.elements.NonlinearElement(
        simulation_parameters=sim_params,
        response_function=lambda x: x**2,
    ),
    delay_element=sv.elements.FreeSpace(
        simulation_parameters=sim_params, distance=0.2, method="AS"
    ),
    feedback_gain=0.5,
    input_gain=0.5,
    delay=3,
)

for input_wavefront in input_wavefront_sequence:
    output = reservoir(input_wavefront)

# clear the delay line before the next sequence or batch
reservoir.drop_feedback_queue()

show_structure(reservoir)
Output (in IPython environment):

append_feedback_queue

append_feedback_queue(field: Wavefront)

Append a new wavefront to the feedback queue.

Parameters:

  • field (Wavefront) –

    The new wavefront to be added to the end of the queue.

pop_feedback_queue

pop_feedback_queue() -> None | Wavefront

Retrieve and remove the first element from the feedback queue if available.

Returns:

  • None | Wavefront

    The first wavefront in the queue if the queue is not empty; otherwise, None.

drop_feedback_queue

drop_feedback_queue() -> None

Clear all elements from the feedback queue.