Stream explicit GRU state
Carry detached recurrent state across chunks and perform explicit truncated backpropagation updates.
// Explicit state creates a detached graph boundary for streaming and TBPTT.
import aner.nn
import aner.tensor
let x = tensor.reshape(nn.random(2, 4, seed: 7, scale: 0.2), List(2, 4, 1))
let y = nn.zeros(2, 1)
let model = nn.gru(1, 8).on("cpu")
let start = model.initial_state(batch: 2)
let first = model.step(x, start, lengths: List(4, 2))
let next = model.step(x, first.state())
print(next.values().rows())
let fitted = model.fit_chunk(x, y, start, rate: 0.001, clip_norm: 1.0)
let continued = fitted.fit_chunk(x, y, fitted.state())
print(continued.updates())
// Keep stream identity/order stable across chunks. Reset at series boundaries.
Make it your experiment.
Use Aner 0.0.3 or newer. Save this program as examples/recurrent_streaming.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/recurrent_streaming.aner
aner run examples/recurrent_streaming.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Requires Aner 0.0.4 or newer and matching editor integration. Uses synthetic tensors with no external dataset, credentials or network connection. Supported Mac packages include Metal/MPS; current Linux and Windows packages do not include CUDA or MPI/NCCL. Optional source backends require a compatible runtime and hardware.
aner check examples/recurrent_streaming.aner
aner examples/recurrent_streaming.anerBundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution