hardware_rc.reservoir¶
Filename: reservoir.py
- Description:
A class that simulates the dynamics of a reservoir computer with an RK4 DDE solver.
It is built with JAX, specifically JIT compilation, for speed.
It should be able to handle any given DDE equation with possibly some input changes.
Classes
|
|
|
- class hardware_rc.reservoir.AnalyzeReservoir(reservoir)[source]¶
Bases:
object- plot_Vin(*, title_addition='', save=False, folder_path=None, base_file_name='', figsize=(3.5, 3), ax=None, show=True, color='black', state=[0, 0, 0, 0], Vin=None, partial_N=None, state2=None, color2='orange')[source]¶
- plot_mask(*, together=True, separate=True, combined=True, cmap_color='tab10', title_addition='', save=False, folder_path=None, base_file_name='', figsize=(3.5, 3), ax=None, show=True, color='royalblue', partial_N=None)[source]¶
- plot_response(data, *, points=None, title=None, save=False, folder_path=None, base_file_name='', overlay_mask=False, Vin=None, show=True, figsize=(10, 5), show_neuron_sat=False, neuron_sat=None, reps, return_image=False, ax=None, color='royalblue', color2=None, x_on=True, one_y=False)[source]¶
- reservoir_response_subplots_2_mc(*, figsize=(3.5, 2.5), dpi=150, states=None, show=True, save=True, folder_path=None, file_name=None)[source]¶
- reservoir_response_subplots_3(*, figsize=(3.5, 2.5), dpi=150, states=None, show=True, save=True, folder_path=None, file_name=None)[source]¶
- reservoir_response_subplots_3_mc(*, figsize=(3.5, 2.5), dpi=150, states=None, show=True, save=True, folder_path=None, file_name=None)[source]¶
- reservoir_response_subplots_4(*, figsize=(3.5, 2.5), dpi=150, states=None, show=True, save=True, folder_path=None, file_name=None)[source]¶
- reservoir_response_subplots_4_mc(*, figsize=(3.5, 2.5), dpi=150, states=None, show=True, save=True, folder_path=None, file_name=None)[source]¶
- reservoir_subplots(*, figsize=(3.5, 2.5), dpi=150, states=None, show=True, save=True, folder_path=None, file_name=None)[source]¶
- sim_response(*, state=None, seed=None, overlay_mask=False, overlay_Vin=False, overlay_actual_Vin=True, title=None, save=False, folder_path=None, base_file_name='', show=True, figsize=(10, 5), show_neuron_sat=False, reps=1, return_image=False, states=None, ax=None, color='royalblue', color2='royalblue', x_on=True, one_y=False)[source]¶
- class hardware_rc.reservoir.Reservoir(*, h=0.02, theta, N, sd=0, amp=1, tau=0, fb_gain=0, norm_factor=None, norm_offset=None, state_shape=None, input_connectivity=None, mask=None, mask_seed=0, load=False, normalize_mask=True, VDC=20)[source]¶
Bases:
object- static diff_eq(y, V, amp, VDC)[source]¶
MEMS differential equation.
- Parameters:
y (jnp.ndarray) – Current state of the MEMS device [position, velocity].
V (jnp.ndarray) – Input voltage at current time [Volts].
amp (jnp.float) – Amplification parameter for the reservoir.
- static rk4(*, n_steps, pos_buf, vel_buf, h, Vin, theta, N, sd, amp, stride, tau, fb_gain, buf_idx, buf_cnt, VDC)[source]¶
Simulate and sample a DDE for a given set of step input voltages with RK4 and cubic Hermite interpolation for the delay term. The state of the DDE is stored in ring buffers to allow for efficient and JAX correct sampling and delayed feedback.
- Parameters:
n_steps (int) – total number of simulation steps.
pos_buf (jnp.ndarray) – ring buffer to store past positions, length buf_len.
vel_buf (jnp.ndarray) – ring buffer to store past velocities, length buf_len.
h (float) – step size for the simulation.
Vin (jnp.ndarray) – input voltage array, length n_steps.
theta (float) – sample time for one reservoir reading [non-dimensional].
N (int) – number of reservoir states.
sd (int) – sample delay (in timesteps).
stride (int) – sample every ‘stride’ with delay ‘start’.
tau (float) – delayed feedback gain parameter [non-dimensional].
fb_gain (float) – feedback gain parameter [non-dimensional].
amp (float) – amplitude of the input voltage [non-dimensional].
buf_idx (int) – next write index (most recent sample is at buf_idx-1).
buf_cnt (int) – number of valid samples in buffers (<= len(pos_buf)).
VDC (float) – DC offset voltage [V].
- Returns:
all positions from simulation. sampled (jnp.ndarray): sampled positions (neuron values), length n_samples. pbuf_out (jnp.ndarray): updated ring buffer of past positions. vbuf_out (jnp.ndarray): updated ring buffer of past velocities. buf_idx_out (int): updated next write index. buf_count_out (int): updated number of valid samples in buffers.
- Return type:
positions (jnp.ndarray)