pub struct Constant<S: Shaped + IntoSpec>(pub S);Expand description
Source node for numerical constants.
This node implements both Function and Differentiable. The former simply returns the wrapped value, and the latter returns an instance of ConstantAdjoint that handles (empty) buffer shaping.
§Examples
let cns = Constant([10.0, 10.0]);
let jac = cns.adjoint(X);
assert_eq!(cns.evaluate(ctx!{X = [1.0, 2.0]}).unwrap(), [10.0, 10.0]);
assert_eq!(jac.evaluate(ctx!{X = [1.0, 2.0]}).unwrap(), [
[0.0, 0.0],
[0.0, 0.0]
]);Tuple Fields§
§0: STrait Implementations§
Source§impl<T, B> Differentiable<T> for Constant<B>
impl<T, B> Differentiable<T> for Constant<B>
Source§type Adjoint = ConstantAdjoint<Constant<B>, T>
type Adjoint = ConstantAdjoint<Constant<B>, T>
The adjoint operator; i.e. the gradient.
Source§fn evaluate_adjoint<C: Context, CR: AsRef<C>>(
&self,
target: T,
ctx: CR,
) -> AegirResult<Self::Adjoint, C>
fn evaluate_adjoint<C: Context, CR: AsRef<C>>( &self, target: T, ctx: CR, ) -> AegirResult<Self::Adjoint, C>
Helper method that computes the adjoint and evaluates its value. Read more
Source§impl<C, S> Function<C> for Constant<S>
impl<C, S> Function<C> for Constant<S>
Source§impl<S: Shaped + IntoSpec> Node for Constant<S>
impl<S: Shaped + IntoSpec> Node for Constant<S>
fn add<N: Node>(self, other: N) -> Add<Self, N>where
Self: Sized,
fn sub<N: Node>(self, other: N) -> Sub<Self, N>where
Self: Sized,
fn mul<N: Node>(self, other: N) -> Mul<Self, N>where
Self: Sized,
fn div<N: Node>(self, other: N) -> Div<Self, N>where
Self: Sized,
fn dot<N: Node>(self, other: N) -> TensorDot<Self, N>where
Self: Sized,
fn abs(self) -> Abs<Self>where
Self: Sized,
fn neg(self) -> Negate<Self>where
Self: Sized,
fn pow<P>(self, power: P) -> Power<Self, P>where
Self: Sized,
fn ln(self) -> Ln<Self>where
Self: Sized,
fn squared(self) -> Square<Self>where
Self: Sized,
fn sum(self) -> Sum<Self>where
Self: Sized,
fn sigmoid(self) -> Sigmoid<Self>where
Self: Sized,
impl<S: Copy + Shaped + IntoSpec> Copy for Constant<S>
impl<S: Eq + Shaped + IntoSpec> Eq for Constant<S>
impl<S: Shaped + IntoSpec> StructuralPartialEq for Constant<S>
Auto Trait Implementations§
impl<S> Freeze for Constant<S>where
S: Freeze,
impl<S> RefUnwindSafe for Constant<S>where
S: RefUnwindSafe,
impl<S> Send for Constant<S>where
S: Send,
impl<S> Sync for Constant<S>where
S: Sync,
impl<S> Unpin for Constant<S>where
S: Unpin,
impl<S> UnwindSafe for Constant<S>where
S: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more