pub struct NetworkHandle {
pub name: String,
pub module: Option<PyObject>,
pub optimizer: Option<PyObject>,
pub scheduler: Option<PyObject>,
pub batching: bool,
pub k: Option<usize>,
pub det: bool,
pub train_mode: bool,
pub cache_enabled: bool,
pub cache_size: usize,
}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 PyObject references.
Fields§
§name: StringUnique name identifying this network
module: Option<PyObject>The PyTorch nn.Module (set via Python API)
Only available with the python feature
optimizer: Option<PyObject>The optimizer for training (e.g., Adam, SGD)
Only available with the python feature
scheduler: Option<PyObject>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
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: PyObject)
pub fn set_module(&mut self, module: PyObject)
Set the PyTorch module.
Sourcepub fn set_optimizer(&mut self, optimizer: PyObject)
pub fn set_optimizer(&mut self, optimizer: PyObject)
Set the optimizer.
Sourcepub fn set_scheduler(&mut self, scheduler: PyObject)
pub fn set_scheduler(&mut self, scheduler: PyObject)
Set the learning rate scheduler.