Struct AddOne

Source
pub struct AddOne<N>(pub N);
Expand description

Operator that applies f[g](x) = g(x) + 1 element-wise to a buffer.

§Examples

let f = AddOne(X.into_var());

assert_eq!(f.evaluate_dual(X, ctx!{X = 1.0}).unwrap(), dual!(2.0, 1.0));
assert_eq!(f.evaluate_dual(X, ctx!{X = 0.0}).unwrap(), dual!(1.0, 1.0));
assert_eq!(f.evaluate_dual(X, ctx!{X = -1.0}).unwrap(), dual!(0.0, 1.0));

Tuple Fields§

§0: N

Trait Implementations§

Source§

impl<N: Clone> Clone for AddOne<N>

Source§

fn clone(&self) -> AddOne<N>

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

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

Performs copy-assignment from source. Read more
Source§

impl<N, I: Identifier> Contains<I> for AddOne<N>
where N: Contains<I>,

Source§

fn contains(&self, target: I) -> bool

Returns true if the identifier is present in the expression.
Source§

impl<N: Debug> Debug for AddOne<N>

Source§

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

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

impl<T, N> Differentiable<T> for AddOne<N>
where T: Identifier, N: Differentiable<T>,

Source§

type Adjoint = <N as Differentiable<T>>::Adjoint

The adjoint operator; i.e. the gradient.
Source§

fn adjoint(&self, target: T) -> Self::Adjoint

Transform the node into its Adjoint operator tree. Read more
Source§

fn evaluate_adjoint<C: Context, CR: AsRef<C>>( &self, target: T, ctx: CR, ) -> AegirResult<Self::Adjoint, C>
where Self: Function<C>, Self::Adjoint: Function<C>,

Helper method that computes the adjoint and evaluates its value. Read more
Source§

fn evaluate_dual<C: Context, CR: AsRef<C>>( &self, target: T, ctx: CR, ) -> Result<DualOf<Self, C, T>, BinaryError<Self::Error, <AdjointOf<Self, T> as Function<C>>::Error, NoError>>
where Self: Function<C>, Self::Adjoint: Function<C>,

Helper method that evaluates the function and its adjoint, wrapping up in a Dual.
Source§

impl<N: ToExpr> Display for AddOne<N>

Source§

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

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

impl<C, N, F> Function<C> for AddOne<N>
where C: Context, N: Function<C>, F: Scalar + Scalar, N::Value: Buffer<Field = F>,

Source§

type Error = <N as Function<C>>::Error

The error type of the function.
Source§

type Value = <N as Function<C>>::Value

The codomain of the function.
Source§

fn evaluate<CR: AsRef<C>>(&self, ctx: CR) -> Result<Self::Value, Self::Error>

Evaluate the function and return its Value. Read more
Source§

fn evaluate_spec<CR: AsRef<C>>( &self, ctx: CR, ) -> Result<Spec<Self::Value>, Self::Error>

Evaluate the function and return its lifted Value. Read more
Source§

fn evaluate_shape<CR: AsRef<C>>( &self, ctx: CR, ) -> Result<ShapeOf<Self::Value>, Self::Error>

Evaluate the function and return the shape of the Value. Read more
Source§

impl<N: Node> Node for AddOne<N>

Source§

fn add<N: Node>(self, other: N) -> Add<Self, N>
where Self: Sized,

Source§

fn sub<N: Node>(self, other: N) -> Sub<Self, N>
where Self: Sized,

Source§

fn mul<N: Node>(self, other: N) -> Mul<Self, N>
where Self: Sized,

Source§

fn div<N: Node>(self, other: N) -> Div<Self, N>
where Self: Sized,

Source§

fn dot<N: Node>(self, other: N) -> TensorDot<Self, N>
where Self: Sized,

Source§

fn abs(self) -> Abs<Self>
where Self: Sized,

Source§

fn neg(self) -> Negate<Self>
where Self: Sized,

Source§

fn pow<P>(self, power: P) -> Power<Self, P>
where Self: Sized,

Source§

fn ln(self) -> Ln<Self>
where Self: Sized,

Source§

fn squared(self) -> Square<Self>
where Self: Sized,

Source§

fn sum(self) -> Sum<Self>
where Self: Sized,

Source§

fn sigmoid(self) -> Sigmoid<Self>
where Self: Sized,

Source§

impl<N: PartialEq> PartialEq for AddOne<N>

Source§

fn eq(&self, other: &AddOne<N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<N: ToExpr> ToExpr for AddOne<N>

Source§

fn to_expr(&self) -> Expr

Convert the node to an expression string. Read more
Source§

impl<N: Copy> Copy for AddOne<N>

Source§

impl<N> StructuralPartialEq for AddOne<N>

Auto Trait Implementations§

§

impl<N> Freeze for AddOne<N>
where N: Freeze,

§

impl<N> RefUnwindSafe for AddOne<N>
where N: RefUnwindSafe,

§

impl<N> Send for AddOne<N>
where N: Send,

§

impl<N> Sync for AddOne<N>
where N: Sync,

§

impl<N> Unpin for AddOne<N>
where N: Unpin,

§

impl<N> UnwindSafe for AddOne<N>
where N: UnwindSafe,

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.