[−][src]Struct melange::backprop::variable::Variable
Core type of backprop
module that represents a node in the computation
graph. It contains a combination of Rc
and RefCell
to allow
mutable reference counting of the actual BackpropNode
s.
Implementations
impl<T, S, C, L, P, Lgrad, Cback, Lback, Pback> Variable<T, S, C, L, P, Lgrad, Cback, Lback, Pback> where
Tensor<T, S, Contiguous, Lgrad, P>: Clone,
[src]
Tensor<T, S, Contiguous, Lgrad, P>: Clone,
pub fn grad(&self) -> Option<Tensor<T, S, Contiguous, Lgrad, P>>
[src]
impl<T, S, C, L, P, Cback, Lback, Pback> Variable<T, S, C, L, P, P::Layout, Cback, Lback, Pback> where
S: StaticShape,
L: for<'a> Layout<'a, T>,
P: StaticAllocationPolicy<T, S>,
[src]
S: StaticShape,
L: for<'a> Layout<'a, T>,
P: StaticAllocationPolicy<T, S>,
pub fn backward(&self, grad: Tensor<T, S, Cback, Lback, Pback>) where
T: Send + Sync + Copy + AddAssign,
Lback: for<'a> Layout<'a, T>,
[src]
T: Send + Sync + Copy + AddAssign,
Lback: for<'a> Layout<'a, T>,
Add given gradient to the retained gradient if needed and backpropagate using the closure.
To initiate backpropagation a tensor full of ones is a good choice.
pub fn new(tensor: Tensor<T, S, C, L, P>, require_grad: bool) -> Self
[src]
Create a new variable that retains its gradient if require_grad is true by moving the given tensor.
impl<T, S, C, L, P, Cback, Lback, Pback> Variable<T, S, C, L, P, P::Layout, Cback, Lback, Pback> where
L: for<'a> Layout<'a, T>,
P: DynamicAllocationPolicy<T>,
[src]
L: for<'a> Layout<'a, T>,
P: DynamicAllocationPolicy<T>,
pub fn backward_dynamic(&self, grad: Tensor<T, S, Cback, Lback, Pback>) where
T: Send + Sync + Copy + AddAssign,
P: DynamicAllocationPolicy<T>,
P::Layout: for<'a> Layout<'a, T>,
Lback: for<'a> Layout<'a, T>,
[src]
T: Send + Sync + Copy + AddAssign,
P: DynamicAllocationPolicy<T>,
P::Layout: for<'a> Layout<'a, T>,
Lback: for<'a> Layout<'a, T>,
Dynamic version of the backpropagation function. Name has to be different because specialization is not yet available in stable Rust.
Add given gradient to the retained gradient if needed and backpropagate using the closure.
To initiate backpropagation a tensor full of ones is a good choice.
Methods from Deref<Target = Rc<RefCell<BackpropNode<T, S, C, L, P, Lgrad, Cback, Lback, Pback>>>>
Trait Implementations
impl<T, S, C, L, P, Cback, Lback, Pback> Add<T> for Variable<T, S, C, L, P, P::Layout, Cback, Lback, Pback> where
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + Add<Output = T> + 'static,
[src]
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + Add<Output = T> + 'static,
type Output = Variable<T, S, Contiguous, P::Layout, P, P::Layout, Cback, Lback, Pback>
The resulting type after applying the +
operator.
fn add(self, param: T) -> Self::Output
[src]
impl<T, S, C, L, P, Cback, Lback, Pback, Crhs, Lrhs, Prhs> Add<Variable<T, S, Crhs, Lrhs, Prhs, <Prhs as StaticAllocationPolicy<T, S>>::Layout, Contiguous, <Pback as StaticAllocationPolicy<T, S>>::Layout, Pback>> for Variable<T, S, C, L, P, P::Layout, Cback, Lback, Pback> where
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Crhs: 'static,
Prhs: StaticAllocationPolicy<T, S> + 'static,
Prhs::Layout: for<'a> Layout<'a, T> + 'static,
Lrhs: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + Add<Output = T> + 'static,
[src]
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Crhs: 'static,
Prhs: StaticAllocationPolicy<T, S> + 'static,
Prhs::Layout: for<'a> Layout<'a, T> + 'static,
Lrhs: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + Add<Output = T> + 'static,
type Output = Variable<T, S, Contiguous, P::Layout, P, P::Layout, Cback, Lback, Pback>
The resulting type after applying the +
operator.
fn add(
self,
other: Variable<T, S, Crhs, Lrhs, Prhs, Prhs::Layout, Contiguous, Pback::Layout, Pback>
) -> Self::Output
[src]
self,
other: Variable<T, S, Crhs, Lrhs, Prhs, Prhs::Layout, Contiguous, Pback::Layout, Pback>
) -> Self::Output
impl<T, S, C, L, P, Lgrad, Cback, Lback, Pback> Clone for Variable<T, S, C, L, P, Lgrad, Cback, Lback, Pback>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T, S, C, L, P, Lgrad, Cback, Lback, Pback> Debug for Variable<T, S, C, L, P, Lgrad, Cback, Lback, Pback> where
T: Debug,
S: Debug,
C: Debug,
L: Debug,
P: Debug,
Lgrad: Debug,
[src]
T: Debug,
S: Debug,
C: Debug,
L: Debug,
P: Debug,
Lgrad: Debug,
impl<T, S, C, L, P, Lgrad, Cback, Lback, Pback> Deref for Variable<T, S, C, L, P, Lgrad, Cback, Lback, Pback>
[src]
type Target = Rc<RefCell<BackpropNode<T, S, C, L, P, Lgrad, Cback, Lback, Pback>>>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl<T, S, C, L, P, Cback, Lback, Pback> Div<T> for Variable<T, S, C, L, P, P::Layout, Cback, Lback, Pback> where
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + Div<Output = T> + Mul<Output = T> + Ring + 'static,
[src]
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + Div<Output = T> + Mul<Output = T> + Ring + 'static,
type Output = Variable<T, S, Contiguous, P::Layout, P, P::Layout, Cback, Lback, Pback>
The resulting type after applying the /
operator.
fn div(self, param: T) -> Self::Output
[src]
impl<T, S, C, L, P, Cback, Lback, Pback, Crhs, Lrhs, Prhs> Div<Variable<T, S, Crhs, Lrhs, Prhs, <Prhs as StaticAllocationPolicy<T, S>>::Layout, Contiguous, <Pback as StaticAllocationPolicy<T, S>>::Layout, Pback>> for Variable<T, S, C, L, P, P::Layout, Cback, Lback, Pback> where
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Crhs: 'static,
Prhs: StaticAllocationPolicy<T, S> + 'static,
Prhs::Layout: for<'a> Layout<'a, T> + 'static,
Lrhs: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + DivAssign + Div<Output = T> + Mul<Output = T> + 'static,
[src]
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Crhs: 'static,
Prhs: StaticAllocationPolicy<T, S> + 'static,
Prhs::Layout: for<'a> Layout<'a, T> + 'static,
Lrhs: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + DivAssign + Div<Output = T> + Mul<Output = T> + 'static,
type Output = Variable<T, S, Contiguous, P::Layout, P, P::Layout, Cback, Lback, Pback>
The resulting type after applying the /
operator.
fn div(
self,
other: Variable<T, S, Crhs, Lrhs, Prhs, Prhs::Layout, Contiguous, Pback::Layout, Pback>
) -> Self::Output
[src]
self,
other: Variable<T, S, Crhs, Lrhs, Prhs, Prhs::Layout, Contiguous, Pback::Layout, Pback>
) -> Self::Output
impl<T, S, C, L, P, Cback, Lback, Pback> Mul<T> for Variable<T, S, C, L, P, P::Layout, Cback, Lback, Pback> where
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + Mul<Output = T> + 'static,
[src]
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + Mul<Output = T> + 'static,
type Output = Variable<T, S, Contiguous, P::Layout, P, P::Layout, Cback, Lback, Pback>
The resulting type after applying the *
operator.
fn mul(self, param: T) -> Self::Output
[src]
impl<T, S, C, L, P, Cback, Lback, Pback, Crhs, Lrhs, Prhs> Mul<Variable<T, S, Crhs, Lrhs, Prhs, <Prhs as StaticAllocationPolicy<T, S>>::Layout, Contiguous, <Pback as StaticAllocationPolicy<T, S>>::Layout, Pback>> for Variable<T, S, C, L, P, P::Layout, Cback, Lback, Pback> where
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Crhs: 'static,
Prhs: StaticAllocationPolicy<T, S> + 'static,
Prhs::Layout: for<'a> Layout<'a, T> + 'static,
Lrhs: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + MulAssign + Mul<Output = T> + 'static,
[src]
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Crhs: 'static,
Prhs: StaticAllocationPolicy<T, S> + 'static,
Prhs::Layout: for<'a> Layout<'a, T> + 'static,
Lrhs: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + MulAssign + Mul<Output = T> + 'static,
type Output = Variable<T, S, Contiguous, P::Layout, P, P::Layout, Cback, Lback, Pback>
The resulting type after applying the *
operator.
fn mul(
self,
other: Variable<T, S, Crhs, Lrhs, Prhs, Prhs::Layout, Contiguous, Pback::Layout, Pback>
) -> Self::Output
[src]
self,
other: Variable<T, S, Crhs, Lrhs, Prhs, Prhs::Layout, Contiguous, Pback::Layout, Pback>
) -> Self::Output
impl<T, S, C, L, P, Cback, Lback, Pback> Sub<T> for Variable<T, S, C, L, P, P::Layout, Cback, Lback, Pback> where
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + Sub<Output = T> + 'static,
[src]
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + Sub<Output = T> + 'static,
type Output = Variable<T, S, Contiguous, P::Layout, P, P::Layout, Cback, Lback, Pback>
The resulting type after applying the -
operator.
fn sub(self, param: T) -> Self::Output
[src]
impl<T, S, C, L, P, Cback, Lback, Pback, Crhs, Lrhs, Prhs> Sub<Variable<T, S, Crhs, Lrhs, Prhs, <Prhs as StaticAllocationPolicy<T, S>>::Layout, Contiguous, <Pback as StaticAllocationPolicy<T, S>>::Layout, Pback>> for Variable<T, S, C, L, P, P::Layout, Cback, Lback, Pback> where
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Crhs: 'static,
Prhs: StaticAllocationPolicy<T, S> + 'static,
Prhs::Layout: for<'a> Layout<'a, T> + 'static,
Lrhs: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + Sub<Output = T> + Ring + Neg<Output = T> + Mul<Output = T> + 'static,
[src]
S: StaticShape + 'static,
C: 'static,
L: for<'a> Layout<'a, T> + 'static,
P: StaticAllocationPolicy<T, S> + 'static,
P::Layout: for<'a> Layout<'a, T> + 'static,
Crhs: 'static,
Prhs: StaticAllocationPolicy<T, S> + 'static,
Prhs::Layout: for<'a> Layout<'a, T> + 'static,
Lrhs: for<'a> Layout<'a, T> + 'static,
Cback: 'static,
Lback: for<'a> Layout<'a, T> + for<'a> LayoutMut<'a, T> + 'static,
Pback: StaticAllocationPolicy<T, S> + 'static,
Pback::Layout: for<'a> Layout<'a, T> + 'static,
T: Send + Sync + Copy + AddAssign + Sub<Output = T> + Ring + Neg<Output = T> + Mul<Output = T> + 'static,
Auto Trait Implementations
impl<T, S, C, L, P, Lgrad, Cback, Lback, Pback> !RefUnwindSafe for Variable<T, S, C, L, P, Lgrad, Cback, Lback, Pback>
impl<T, S, C, L, P, Lgrad, Cback, Lback, Pback> !Send for Variable<T, S, C, L, P, Lgrad, Cback, Lback, Pback>
impl<T, S, C, L, P, Lgrad, Cback, Lback, Pback> !Sync for Variable<T, S, C, L, P, Lgrad, Cback, Lback, Pback>
impl<T, S, C, L, P, Lgrad, Cback, Lback, Pback> Unpin for Variable<T, S, C, L, P, Lgrad, Cback, Lback, Pback>
impl<T, S, C, L, P, Lgrad, Cback, Lback, Pback> !UnwindSafe for Variable<T, S, C, L, P, Lgrad, Cback, Lback, Pback>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,