spires_compute_output
Compute the readout output vector from the reservoir’s current state: y = W_out * x.
Signature
spires_status spires_compute_output(spires_reservoir *r, double *out);Parameters
| Parameter | Type | Description |
|---|---|---|
r | spires_reservoir * | Handle to the reservoir. Must not be NULL. |
out | double * | Caller-allocated array of at least num_outputs elements. The computed output vector is written here. Must not be NULL. |
Returns
spires_status — SPIRES_OK on success, or SPIRES_ERR_INVALID_ARG if r or out is NULL.
Example
size_t no = spires_num_outputs(r);
double *y = malloc(no * sizeof(double));
/* Step and read output */
spires_step(r, input_vec);
spires_compute_output(r, y);
for (size_t k = 0; k < no; k++) {
printf("output[%zu] = %.6f\n", k, y[k]);
}
free(y);Notes
- Readout weights. The output is the matrix-vector product
W_out * x, whereW_outis the[num_outputs x num_neurons]readout weight matrix andxis the current neuron state vector. If no training has been performed,W_outis all zeros and the output will be zero. - No allocation. This function performs no heap allocation. The caller provides the output buffer.
- Buffer sizing. The
outarray must hold at leastnum_outputsdoubles. Usespires_num_outputsto query the required size. - Idempotent. Calling this function does not modify the reservoir state. It can be called multiple times between steps with identical results.
- Thread safety. Safe to call concurrently with other read-only functions (e.g.,
spires_num_neurons) on the same reservoir, but do not call concurrently with mutating functions (e.g.,spires_step,spires_train_online).
See Also
- spires_step — advance the state before computing output.
- spires_train_ridge — train the output weights.
- spires_train_online — update the output weights incrementally.
- spires_num_outputs — query the output dimension.
Last updated on