pub struct Net { /* private fields */ }
Expand description
The computation network. Connection has duplication.
Implementations§
Source§impl Net
impl Net
pub fn new() -> Net
pub fn get_data(&self) -> &GenIndex<Tensor>
pub fn get_data_mut(&mut self) -> &mut GenIndex<Tensor>
pub fn get_ops(&self) -> &GenIndex<Op>
pub fn get_ops_mut(&mut self) -> &mut GenIndex<Op>
pub fn add_tensor(&mut self, t: Tensor) -> GenKey
pub fn get_tensor(&self, id: GenKey) -> Result<Tensor, AutoDiffError>
pub fn set_tensor( &mut self, id: GenKey, val: Tensor, ) -> Result<(), AutoDiffError>
pub fn get_op(&self, id: GenKey) -> Result<Op, AutoDiffError>
pub fn get_grad(&self, id: GenKey) -> Result<Tensor, AutoDiffError>
pub fn get_input_edge_data(&self) -> BTreeSet<GenKey>
pub fn get_output_edge_data(&self) -> BTreeSet<GenKey>
Sourcepub fn connect(&mut self, input: &[GenKey], op: GenKey, output: &[GenKey])
pub fn connect(&mut self, input: &[GenKey], op: GenKey, output: &[GenKey])
Build input-operator-output relation, with given components.
Sourcepub fn set_mark(&mut self, did: &GenKey)
pub fn set_mark(&mut self, did: &GenKey)
set the set_mark, set_mark is used to label var with input value with it.
pub fn unset_mark(&mut self, did: &GenKey)
Sourcepub fn eval(&mut self, starting_node: &[GenKey]) -> Result<(), BTreeSet<GenKey>>
pub fn eval(&mut self, starting_node: &[GenKey]) -> Result<(), BTreeSet<GenKey>>
Forward evaluate the computaiton graph.
pub fn bptt(&mut self, output_grad: &BTreeMap<GenKey, Tensor>)
Sourcepub fn visit_op<F>(
&mut self,
closure: F,
allow: Option<Vec<GenKey>>,
skip: Option<Vec<GenKey>>,
)
pub fn visit_op<F>( &mut self, closure: F, allow: Option<Vec<GenKey>>, skip: Option<Vec<GenKey>>, )
Iterate over all ops, no order guarantee
pub fn visit_data<F>(&mut self, closure: F)
Sourcepub fn append(
&mut self,
other: &Self,
original_keys: &[GenKey],
) -> Result<Vec<GenKey>, AutoDiffError>
pub fn append( &mut self, other: &Self, original_keys: &[GenKey], ) -> Result<Vec<GenKey>, AutoDiffError>
Move content in other network into self. Return new ids for those have origianl_keys in the old network.
Sourcepub fn set_label(
&mut self,
label: &str,
id: &GenKey,
) -> Result<(), AutoDiffError>
pub fn set_label( &mut self, label: &str, id: &GenKey, ) -> Result<(), AutoDiffError>
For introspection.
pub fn get_id_by_label(&self, label: &str) -> Result<GenKey, AutoDiffError>
pub fn drop_label(&mut self, label: &str) -> Result<GenKey, AutoDiffError>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Net
impl<'de> Deserialize<'de> for Net
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Net
impl !RefUnwindSafe for Net
impl !Send for Net
impl !Sync for Net
impl Unpin for Net
impl !UnwindSafe for Net
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more