Expand description
Callback trait and iterator context for training and inference sessions.
Port provenance: oa/core/callback.h, oa/core/iterator.h.
Callback is the Keras-style hook interface used by Training and
any future ItBatch / ItInference session types. All three methods have
default no-op implementations so callers only override what they need.
IteratorContext is a thin object-safe view of the current iterator
state that callbacks receive. Decoupled from the concrete session type so
that callback code does not need to name it.
§Usage
ⓘ
use oa::{Callback, IteratorContext};
struct PrintProgress;
impl Callback for PrintProgress {
fn on_step(&mut self, ctx: &dyn IteratorContext) {
if ctx.index() % 100 == 0 {
println!("step {}/{}", ctx.index(), ctx.total().unwrap_or(0));
}
}
}Structs§
- Callback
Set - Ordered list of
Callbackobjects attached to a session.
Traits§
- Callback
- Keras-style hook interface for OA iterator sessions.
- Iterator
Context - Object-safe view of an iterator’s current state, passed to every
Callbackhook.