Expand description
The policy shell’s ONNX contract, version 1: how a trained policy’s model must look so one generic program runs it in every arena.
- Inputs: one per declared observation, named exactly as declared,
shape
[1, *shape],f32. Au8value is fed asf32 / 255. A policy may use a subset of the observations. - Memory: an optional
state_in: f32[1, S]→state_out: f32[1, S]pair,Sat mostMAX_STATE. Zeros at the start; each turn’sstate_outis the next turn’sstate_in. - Continuous actions (declared
f32): one output per declared action, named as declared, shape[1, *shape], in[-1, 1]. The shell maps each element withto_bounds: clamp to[-1, 1](NaN is 0, the midpoint), then affinely onto the element’s declared bounds. - Discrete actions (declared
u8): one output per declared action, named as declared, of logits shaped[1, *shape, n], where every element shares one range[min, max]andn = max - min + 1. The shell takes the argmax of each element’s logits (argmax) and addsmin. - Metadata:
META_CONTRACT,META_ARENA,META_PAYLOAD_SCHEMA,META_TRAIN_VERSIONandMETA_OPSET, checked against the manifest. - An input named
NOISEis reserved.
botstadia-train implements the same map; the shared golden file
(policy-golden.json, beside this crate’s tests) pins both.
Constants§
- CONTRACT_
VERSION - This contract’s version, as the
botstadia.contractmetadata states it. - EXPORT_
OPSET - The opset the export helper writes.
- GOLDEN
- The golden cases pinning
to_bounds,feed_u8andargmax, whichbotstadia-trainchecks its own implementation against. - MAX_
STATE - The largest memory, in floats.
- META_
ARENA - META_
CONTRACT - META_
OPSET - META_
PAYLOAD_ SCHEMA - META_
TRAIN_ VERSION - NOISE
- Reserved for sampled actions later.
- STATE_
IN - The memory pair’s names.
- STATE_
OUT
Functions§
- argmax
- The index of the largest logit; NaN never wins, and ties go to the first.
- feed_u8
- An observation element as the policy sees it.
- from_
bounds - The inverse of
to_bounds, for training: a declared value as the policy’s[-1, 1]. - to_
bounds - One element of a continuous action: a policy output in
[-1, 1]mapped onto the declared[min, max]. Out-of-range outputs are clamped and NaN is the midpoint, so the result is always valid.