Struct Net

Source
pub struct Net { /* private fields */ }
Expand description

The computation network. Connection has duplication.

Implementations§

Source§

impl Net

Source

pub fn new() -> Net

Source

pub fn get_data(&self) -> &GenIndex<Tensor>

Source

pub fn get_data_mut(&mut self) -> &mut GenIndex<Tensor>

Source

pub fn get_ops(&self) -> &GenIndex<Op>

Source

pub fn get_ops_mut(&mut self) -> &mut GenIndex<Op>

Source

pub fn add_tensor(&mut self, t: Tensor) -> GenKey

Source

pub fn get_tensor(&self, id: GenKey) -> Result<Tensor, AutoDiffError>

Source

pub fn set_tensor( &mut self, id: GenKey, val: Tensor, ) -> Result<(), AutoDiffError>

Source

pub fn add_op(&mut self, op: Op) -> GenKey

Insert operator into the network.

Source

pub fn get_op(&self, id: GenKey) -> Result<Op, AutoDiffError>

Source

pub fn get_grad(&self, id: GenKey) -> Result<Tensor, AutoDiffError>

Source

pub fn get_input_edge_data(&self) -> BTreeSet<GenKey>

Source

pub fn get_output_edge_data(&self) -> BTreeSet<GenKey>

Source

pub fn connect(&mut self, input: &[GenKey], op: GenKey, output: &[GenKey])

Build input-operator-output relation, with given components.

Source

pub fn set_mark(&mut self, did: &GenKey)

set the set_mark, set_mark is used to label var with input value with it.

Source

pub fn unset_mark(&mut self, did: &GenKey)

Source

pub fn eval(&mut self, starting_node: &[GenKey]) -> Result<(), BTreeSet<GenKey>>

Forward evaluate the computaiton graph.

Source

pub fn bptt(&mut self, output_grad: &BTreeMap<GenKey, Tensor>)

Source

pub fn visit_op<F>( &mut self, closure: F, allow: Option<Vec<GenKey>>, skip: Option<Vec<GenKey>>, )
where F: Fn(&Op),

Iterate over all ops, no order guarantee

Source

pub fn visit_data<F>(&mut self, closure: F)
where F: Fn(GenKey, &Tensor),

Source

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.

Source

pub fn set_label( &mut self, label: &str, id: &GenKey, ) -> Result<(), AutoDiffError>

For introspection.

Source

pub fn get_id_by_label(&self, label: &str) -> Result<GenKey, AutoDiffError>

Source

pub fn drop_label(&mut self, label: &str) -> Result<GenKey, AutoDiffError>

Trait Implementations§

Source§

impl Clone for Net

Source§

fn clone(&self) -> Net

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Net

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Net

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Net

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Net

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,