Trait gad::net::Net[][src]

pub trait Net<Algebra: HasGradientReader> {
    type Input;
    type Output;
    type Weights;
    type GradientInfo;
    fn eval_with_gradient_info(
        &self,
        graph: &mut Algebra,
        input: Self::Input
    ) -> Result<(Self::Output, Self::GradientInfo)>;
fn get_weights(&self) -> Self::Weights;
fn update_weights(&mut self, delta: Self::Weights) -> Result<()>;
fn set_weights(&mut self, weight: Self::Weights) -> Result<()>;
fn read_weight_gradients(
        &self,
        info: Self::GradientInfo,
        reader: &Algebra::GradientReader
    ) -> Result<Self::Weights>; fn eval(
        &self,
        graph: &mut Algebra,
        input: Self::Input
    ) -> Result<Self::Output> { ... }
fn map<F, O>(self, f: F) -> Map<Self, F>
    where
        Self: Sized,
        F: Fn(&mut Algebra, Self::Output) -> Result<O>
, { ... }
fn using<N>(self, net: N) -> Using<Self, N>
    where
        Self: Sized,
        N: Net<Algebra, Input = ()>
, { ... }
fn then<N>(self, net: N) -> Then<Self, N>
    where
        Self: Sized,
        N: Net<Algebra, Input = Self::Output>
, { ... }
fn and<N>(self, net: N) -> (Self, N)
    where
        Self: Sized,
        N: Net<Algebra>
, { ... } }

A Neural Network over an algebra of operations.

Associated Types

type Input[src]

Input of the network.

type Output[src]

Output of the network.

type Weights[src]

External representation for the weights of the network.

type GradientInfo[src]

How to read the gradients of the weights after a backward pass.

Loading content...

Required methods

fn eval_with_gradient_info(
    &self,
    graph: &mut Algebra,
    input: Self::Input
) -> Result<(Self::Output, Self::GradientInfo)>
[src]

fn get_weights(&self) -> Self::Weights[src]

fn update_weights(&mut self, delta: Self::Weights) -> Result<()>[src]

fn set_weights(&mut self, weight: Self::Weights) -> Result<()>[src]

fn read_weight_gradients(
    &self,
    info: Self::GradientInfo,
    reader: &Algebra::GradientReader
) -> Result<Self::Weights>
[src]

Loading content...

Provided methods

fn eval(&self, graph: &mut Algebra, input: Self::Input) -> Result<Self::Output>[src]

fn map<F, O>(self, f: F) -> Map<Self, F> where
    Self: Sized,
    F: Fn(&mut Algebra, Self::Output) -> Result<O>, 
[src]

fn using<N>(self, net: N) -> Using<Self, N> where
    Self: Sized,
    N: Net<Algebra, Input = ()>, 
[src]

fn then<N>(self, net: N) -> Then<Self, N> where
    Self: Sized,
    N: Net<Algebra, Input = Self::Output>, 
[src]

fn and<N>(self, net: N) -> (Self, N) where
    Self: Sized,
    N: Net<Algebra>, 
[src]

Loading content...

Implementations on Foreign Types

impl<Algebra: HasGradientReader> Net<Algebra> for ()[src]

type Input = ()

type Output = ()

type Weights = ()

type GradientInfo = ()

impl<Algebra: HasGradientReader, A: Net<Algebra>> Net<Algebra> for (A,)[src]

type Input = (A::Input,)

type Output = (A::Output,)

type Weights = (A::Weights,)

type GradientInfo = (A::GradientInfo,)

impl<Algebra: HasGradientReader, A: Net<Algebra>, B: Net<Algebra>> Net<Algebra> for (A, B)[src]

type Input = (A::Input, B::Input)

type Output = (A::Output, B::Output)

type Weights = (A::Weights, B::Weights)

type GradientInfo = (A::GradientInfo, B::GradientInfo)

impl<Algebra: HasGradientReader, A: Net<Algebra>, B: Net<Algebra>, C: Net<Algebra>> Net<Algebra> for (A, B, C)[src]

type Input = (A::Input, B::Input, C::Input)

type Output = (A::Output, B::Output, C::Output)

type Weights = (A::Weights, B::Weights, C::Weights)

type GradientInfo = (A::GradientInfo, B::GradientInfo, C::GradientInfo)

impl<Algebra: HasGradientReader, A: Net<Algebra>, B: Net<Algebra>, C: Net<Algebra>, D: Net<Algebra>> Net<Algebra> for (A, B, C, D)[src]

type Input = (A::Input, B::Input, C::Input, D::Input)

type Output = (A::Output, B::Output, C::Output, D::Output)

type Weights = (A::Weights, B::Weights, C::Weights, D::Weights)

type GradientInfo = (A::GradientInfo, B::GradientInfo, C::GradientInfo, D::GradientInfo)

impl<Algebra: HasGradientReader, A: Net<Algebra>, B: Net<Algebra>, C: Net<Algebra>, D: Net<Algebra>, E: Net<Algebra>> Net<Algebra> for (A, B, C, D, E)[src]

type Input = (A::Input, B::Input, C::Input, D::Input, E::Input)

type Output = (A::Output, B::Output, C::Output, D::Output, E::Output)

type Weights = (A::Weights, B::Weights, C::Weights, D::Weights, E::Weights)

type GradientInfo = (A::GradientInfo, B::GradientInfo, C::GradientInfo, D::GradientInfo, E::GradientInfo)

impl<Algebra: HasGradientReader, A: Net<Algebra>, B: Net<Algebra>, C: Net<Algebra>, D: Net<Algebra>, E: Net<Algebra>, F: Net<Algebra>> Net<Algebra> for (A, B, C, D, E, F)[src]

type Input = (A::Input, B::Input, C::Input, D::Input, E::Input, F::Input)

type Output = (A::Output, B::Output, C::Output, D::Output, E::Output, F::Output)

type Weights = (A::Weights, B::Weights, C::Weights, D::Weights, E::Weights, F::Weights)

type GradientInfo = (A::GradientInfo, B::GradientInfo, C::GradientInfo, D::GradientInfo, E::GradientInfo, F::GradientInfo)

impl<Algebra: HasGradientReader, A: Net<Algebra>, B: Net<Algebra>, C: Net<Algebra>, D: Net<Algebra>, E: Net<Algebra>, F: Net<Algebra>, G: Net<Algebra>> Net<Algebra> for (A, B, C, D, E, F, G)[src]

type Input = (A::Input, B::Input, C::Input, D::Input, E::Input, F::Input, G::Input)

type Output = (A::Output, B::Output, C::Output, D::Output, E::Output, F::Output, G::Output)

type Weights = (A::Weights, B::Weights, C::Weights, D::Weights, E::Weights, F::Weights, G::Weights)

type GradientInfo = (A::GradientInfo, B::GradientInfo, C::GradientInfo, D::GradientInfo, E::GradientInfo, F::GradientInfo, G::GradientInfo)

impl<Algebra: HasGradientReader, A: Net<Algebra>, B: Net<Algebra>, C: Net<Algebra>, D: Net<Algebra>, E: Net<Algebra>, F: Net<Algebra>, G: Net<Algebra>, H: Net<Algebra>> Net<Algebra> for (A, B, C, D, E, F, G, H)[src]

type Input = (A::Input, B::Input, C::Input, D::Input, E::Input, F::Input, G::Input, H::Input)

type Output = (A::Output, B::Output, C::Output, D::Output, E::Output, F::Output, G::Output, H::Output)

type Weights = (A::Weights, B::Weights, C::Weights, D::Weights, E::Weights, F::Weights, G::Weights, H::Weights)

type GradientInfo = (A::GradientInfo, B::GradientInfo, C::GradientInfo, D::GradientInfo, E::GradientInfo, F::GradientInfo, G::GradientInfo, H::GradientInfo)

impl<Algebra: HasGradientReader, A: Net<Algebra>, B: Net<Algebra>, C: Net<Algebra>, D: Net<Algebra>, E: Net<Algebra>, F: Net<Algebra>, G: Net<Algebra>, H: Net<Algebra>, I: Net<Algebra>> Net<Algebra> for (A, B, C, D, E, F, G, H, I)[src]

type Input = (A::Input, B::Input, C::Input, D::Input, E::Input, F::Input, G::Input, H::Input, I::Input)

type Output = (A::Output, B::Output, C::Output, D::Output, E::Output, F::Output, G::Output, H::Output, I::Output)

type Weights = (A::Weights, B::Weights, C::Weights, D::Weights, E::Weights, F::Weights, G::Weights, H::Weights, I::Weights)

type GradientInfo = (A::GradientInfo, B::GradientInfo, C::GradientInfo, D::GradientInfo, E::GradientInfo, F::GradientInfo, G::GradientInfo, H::GradientInfo, I::GradientInfo)

impl<Algebra: HasGradientReader, A: Net<Algebra>, B: Net<Algebra>, C: Net<Algebra>, D: Net<Algebra>, E: Net<Algebra>, F: Net<Algebra>, G: Net<Algebra>, H: Net<Algebra>, I: Net<Algebra>, J: Net<Algebra>> Net<Algebra> for (A, B, C, D, E, F, G, H, I, J)[src]

type Input = (A::Input, B::Input, C::Input, D::Input, E::Input, F::Input, G::Input, H::Input, I::Input, J::Input)

type Output = (A::Output, B::Output, C::Output, D::Output, E::Output, F::Output, G::Output, H::Output, I::Output, J::Output)

type Weights = (A::Weights, B::Weights, C::Weights, D::Weights, E::Weights, F::Weights, G::Weights, H::Weights, I::Weights, J::Weights)

type GradientInfo = (A::GradientInfo, B::GradientInfo, C::GradientInfo, D::GradientInfo, E::GradientInfo, F::GradientInfo, G::GradientInfo, H::GradientInfo, I::GradientInfo, J::GradientInfo)

impl<Algebra, N> Net<Algebra> for Vec<N> where
    Algebra: HasGradientReader,
    N: Net<Algebra>, 
[src]

type Input = Vec<N::Input>

type Output = Vec<N::Output>

type Weights = Vec<N::Weights>

type GradientInfo = Vec<N::GradientInfo>

Loading content...

Implementors

impl<Algebra, N1, N2> Net<Algebra> for Then<N1, N2> where
    Algebra: HasGradientReader,
    N1: Net<Algebra>,
    N2: Net<Algebra, Input = N1::Output>, 
[src]

type Input = N1::Input

type Output = N2::Output

type Weights = Then<N1::Weights, N2::Weights>

type GradientInfo = Then<N1::GradientInfo, N2::GradientInfo>

impl<Algebra, N1, N2> Net<Algebra> for Using<N1, N2> where
    Algebra: HasGradientReader,
    N1: Net<Algebra>,
    N2: Net<Algebra, Input = ()>, 
[src]

type Input = N1::Input

type Output = (N1::Output, N2::Output)

type Weights = Using<N1::Weights, N2::Weights>

type GradientInfo = Using<N1::GradientInfo, N2::GradientInfo>

impl<Algebra, N, F, O> Net<Algebra> for Map<N, F> where
    Algebra: HasGradientReader,
    N: Net<Algebra>,
    F: Fn(&mut Algebra, N::Output) -> Result<O>, 
[src]

type Input = N::Input

type Output = O

type Weights = N::Weights

type GradientInfo = N::GradientInfo

impl<Data, Algebra, N> Net<Algebra> for SquareLoss<N, Data> where
    Algebra: HasGradientReader + CoreAlgebra<Data, Value = N::Output> + ArrayAlgebra<N::Output> + ArithAlgebra<N::Output> + MatrixAlgebra<N::Output>,
    N: Net<Algebra>,
    Data: HasDims,
    N::Output: HasDims<Dims = Data::Dims>,
    Data::Dims: Clone + PartialEq + Debug
[src]

type Input = (N::Input, Data)

type Output = <Algebra as ArrayAlgebra<N::Output>>::Scalar

type Weights = N::Weights

type GradientInfo = N::GradientInfo

impl<Data, Value, Algebra> Net<Algebra> for ConstantData<Data, Algebra> where
    Data: Clone,
    Algebra: HasGradientReader + CoreAlgebra<Data, Value = Value>, 
[src]

type Input = ()

type Output = Value

type Weights = ()

type GradientInfo = ()

impl<Data, Value, Algebra> Net<Algebra> for WeightData<Data, Algebra> where
    Algebra: HasGradientReader + CoreAlgebra<Data, Value = Value>,
    Data: Clone + HasDims + AddAssign,
    Value: HasGradientId,
    Data::Dims: Clone + PartialEq + Debug,
    Algebra::GradientReader: GradientReader<Value::GradientId, Data>, 
[src]

type Input = ()

type Output = Value

type Weights = Data

type GradientInfo = Value::GradientId

impl<Data, Value, Dims, Algebra> Net<Algebra> for InputData<Data, Algebra> where
    Algebra: HasGradientReader + CoreAlgebra<Data, Value = Value>,
    Data: HasDims<Dims = Dims>,
    Dims: Clone + PartialEq + Debug
[src]

type Input = Data

type Output = Value

type Weights = ()

type GradientInfo = ()

Loading content...