pub struct NetworkRegistry { /* private fields */ }Expand description
Registry for managing neural networks.
The registry maintains a collection of NetworkHandle instances,
each identified by a unique name. Networks are registered with
configurations and then have their PyTorch modules attached via
the Python API.
Implementations§
Source§impl NetworkRegistry
impl NetworkRegistry
Sourcepub fn register(&mut self, config: NetworkConfig)
pub fn register(&mut self, config: NetworkConfig)
Register a network with the given configuration.
If a network with the same name already exists, it will be replaced.
Sourcepub fn get(&self, name: &str) -> Option<&NetworkHandle>
pub fn get(&self, name: &str) -> Option<&NetworkHandle>
Get a reference to a network handle by name.
Sourcepub fn get_mut(&mut self, name: &str) -> Option<&mut NetworkHandle>
pub fn get_mut(&mut self, name: &str) -> Option<&mut NetworkHandle>
Get a mutable reference to a network handle by name.
Sourcepub fn unregister(&mut self, name: &str) -> Option<NetworkHandle>
pub fn unregister(&mut self, name: &str) -> Option<NetworkHandle>
Remove a network from the registry.
Sourcepub fn set_train_mode(&mut self, train: bool)
pub fn set_train_mode(&mut self, train: bool)
Set train mode for all registered networks.
This affects both the train_mode flag on handles and should
be used to call .train() or .eval() on PyTorch modules.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &NetworkHandle)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &NetworkHandle)>
Iterate over all network handles.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = (&str, &mut NetworkHandle)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&str, &mut NetworkHandle)>
Iterate mutably over all network handles.
Sourcepub fn register_embedding(&mut self, handle: EmbeddingHandle)
pub fn register_embedding(&mut self, handle: EmbeddingHandle)
Register an embedding with the given handle.
Sourcepub fn get_embedding(&self, name: &str) -> Option<&EmbeddingHandle>
pub fn get_embedding(&self, name: &str) -> Option<&EmbeddingHandle>
Get a reference to an embedding handle by name.
Sourcepub fn get_embedding_mut(&mut self, name: &str) -> Option<&mut EmbeddingHandle>
pub fn get_embedding_mut(&mut self, name: &str) -> Option<&mut EmbeddingHandle>
Get a mutable reference to an embedding handle by name.
Sourcepub fn contains_embedding(&self, name: &str) -> bool
pub fn contains_embedding(&self, name: &str) -> bool
Check if an embedding is registered.