pub struct NetworkHandle {Show 13 fields
pub name: String,
pub module: Option<Py<PyAny>>,
pub optimizer: Option<Py<PyAny>>,
pub scheduler: Option<Py<PyAny>>,
pub batching: bool,
pub k: Option<usize>,
pub det: bool,
pub train_mode: bool,
pub cache_enabled: bool,
pub cache_size: usize,
pub arity: Option<usize>,
pub arg_sorts: Option<Vec<i64>>,
pub artifact_hash: Option<String>,
}Expand description
Handle to a registered neural network.
This struct holds the PyTorch module and associated training state.
When the python feature is enabled, it can hold PyO3 Py<PyAny> references.
Fields§
§name: StringUnique name identifying this network
module: Option<Py<PyAny>>The PyTorch nn.Module (set via Python API)
Only available with the python feature
optimizer: Option<Py<PyAny>>The optimizer for training (e.g., Adam, SGD)
Only available with the python feature
scheduler: Option<Py<PyAny>>Learning rate scheduler
Only available with the python feature
batching: boolWhether to batch inputs for efficient GPU processing
k: Option<usize>Top-k sampling: if Some(k), only consider top k outputs
det: boolDeterministic mode: use argmax instead of sampling
train_mode: boolWhether the network is in training mode
cache_enabled: boolWhether output caching is enabled
cache_size: usizeMaximum number of cached outputs
arity: Option<usize>Registration-time arity, as passed to register_network (see
NetworkConfig::arity). Carried through unchanged so it can be read
back after registration; the handle does not interpret it.
arg_sorts: Option<Vec<i64>>Registration-time per-argument catalog sort ids (see
NetworkConfig::arg_sorts). Carried through unchanged, like arity.
artifact_hash: Option<String>Registration-time artifact content hash (see NetworkConfig::artifact_hash).
Carried through unchanged, like arity.
Implementations§
Source§impl NetworkHandle
impl NetworkHandle
Sourcepub fn new(name: String) -> Self
pub fn new(name: String) -> Self
Create a new network handle with the given name and default settings.
Sourcepub fn from_config(config: &NetworkConfig) -> Self
pub fn from_config(config: &NetworkConfig) -> Self
Create a handle from a configuration.
Sourcepub fn has_module(&self) -> bool
pub fn has_module(&self) -> bool
Check if the PyTorch module has been set.
Sourcepub fn has_optimizer(&self) -> bool
pub fn has_optimizer(&self) -> bool
Check if an optimizer has been configured.
Sourcepub fn has_scheduler(&self) -> bool
pub fn has_scheduler(&self) -> bool
Check if a scheduler has been configured.
Sourcepub fn set_module(&mut self, module: Py<PyAny>)
pub fn set_module(&mut self, module: Py<PyAny>)
Set the PyTorch module.
Sourcepub fn set_optimizer(&mut self, optimizer: Py<PyAny>)
pub fn set_optimizer(&mut self, optimizer: Py<PyAny>)
Set the optimizer.
Sourcepub fn set_scheduler(&mut self, scheduler: Py<PyAny>)
pub fn set_scheduler(&mut self, scheduler: Py<PyAny>)
Set the learning rate scheduler.