pub struct Sign<N>(pub N);
Expand description
Operator that applies f[g](x) = sgn(g(x))
to a buffer.
Examples
let f = Sign(X.into_var());
assert_eq!(f.evaluate_dual(X, ctx!{X = -1.0}).unwrap(), dual!(-1.0, 0.0));
assert_eq!(f.evaluate_dual(X, ctx!{X = 0.0}).unwrap(), dual!(0.0, INFINITY));
assert_eq!(f.evaluate_dual(X, ctx!{X = 1.0}).unwrap(), dual!(1.0, 0.0));
Tuple Fields§
§0: N
Trait Implementations§
source§impl<T, N> Differentiable<T> for Sign<N>where
T: Identifier,
N: Differentiable<T> + Clone,
impl<T, N> Differentiable<T> for Sign<N>where
T: Identifier,
N: Differentiable<T> + Clone,
§type Adjoint = Mul<Dirac<N>, <N as Differentiable<T>>::Adjoint>
type Adjoint = Mul<Dirac<N>, <N as Differentiable<T>>::Adjoint>
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>where
Self: Function<C>,
Self::Adjoint: Function<C>,
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>,
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.