[][src]Trait auto_diff::op::OpTrait

pub trait OpTrait {
    fn get_name(&self) -> String;
fn apply(&mut self, input: &[&Tensor], output: &[&Tensor]);
fn grad(
        &self,
        input: &[&Tensor],
        output_grad: &[&Tensor],
        input_grad: &[&Tensor]
    );
fn get_values(&self) -> Vec<&Tensor>;
fn set_values(&self, v: &[Tensor]);
fn get_grads(&self) -> Vec<&Tensor>; }

All op is OpTrait

Required methods

fn get_name(&self) -> String

fn apply(&mut self, input: &[&Tensor], output: &[&Tensor])[]

Forward pass

fn grad(
    &self,
    input: &[&Tensor],
    output_grad: &[&Tensor],
    input_grad: &[&Tensor]
)
[]

Given the forward input value and backward output_grad, Update weight gradient. return backward input gradeint.

fn get_values(&self) -> Vec<&Tensor>[]

access weight values

fn set_values(&self, v: &[Tensor])

fn get_grads(&self) -> Vec<&Tensor>[]

access gradient values

Implementors

impl OpTrait for Linear[src][]

impl OpTrait for Add[src][]

impl OpTrait for Div[src][]

impl OpTrait for Mul[src][]

impl OpTrait for Sub[src][]

impl OpTrait for BCEWithLogitsLoss[src][]

fn apply(&mut self, input: &[&Tensor], output: &[&Tensor])[src][]

The first is the prediction, the second input is the label

fn grad(
    &self,
    input: &[&Tensor],
    output_grad: &[&Tensor],
    input_grad: &[&Tensor]
)
[src][]

Given the forward input value and backward output_grad, Update weight gradient. return backward input gradeint.

fn get_values(&self) -> Vec<&Tensor>[src][]

access weight values

fn get_grads(&self) -> Vec<&Tensor>[src][]

access gradient values

impl OpTrait for MSELoss[src][]