Trait collenchyma_nn::Tanh
[−]
[src]
pub trait Tanh<F>: NN<F> { fn tanh(
&self,
x: &mut SharedTensor<F>,
result: &mut SharedTensor<F>
) -> Result<(), Error>; fn tanh_plain(
&self,
x: &SharedTensor<F>,
result: &mut SharedTensor<F>
) -> Result<(), Error>; fn tanh_grad(
&self,
x: &mut SharedTensor<F>,
x_diff: &mut SharedTensor<F>,
result: &mut SharedTensor<F>,
result_diff: &mut SharedTensor<F>
) -> Result<(), Error>; fn tanh_grad_plain(
&self,
x: &SharedTensor<F>,
x_diff: &SharedTensor<F>,
result: &SharedTensor<F>,
result_diff: &mut SharedTensor<F>
) -> Result<(), Error>; }
Provides the functionality for a Backend to support TanH operations.
Required Methods
fn tanh(
&self,
x: &mut SharedTensor<F>,
result: &mut SharedTensor<F>
) -> Result<(), Error>
&self,
x: &mut SharedTensor<F>,
result: &mut SharedTensor<F>
) -> Result<(), Error>
Computes the hyperbolic Tangent over the input Tensor x
with complete memory management.
Saves the result to result
.
For a no-memory managed version see tanh_plain
.
fn tanh_plain(
&self,
x: &SharedTensor<F>,
result: &mut SharedTensor<F>
) -> Result<(), Error>
&self,
x: &SharedTensor<F>,
result: &mut SharedTensor<F>
) -> Result<(), Error>
Computes the tanh over the input Tensor x
without any memory management.
Saves the result to result
.
Attention:
For a correct computation result, you need to manage the memory allocation and synchronization yourself.
For a memory managed version see tanh
.
fn tanh_grad(
&self,
x: &mut SharedTensor<F>,
x_diff: &mut SharedTensor<F>,
result: &mut SharedTensor<F>,
result_diff: &mut SharedTensor<F>
) -> Result<(), Error>
&self,
x: &mut SharedTensor<F>,
x_diff: &mut SharedTensor<F>,
result: &mut SharedTensor<F>,
result_diff: &mut SharedTensor<F>
) -> Result<(), Error>
Computes the gradient of tanh over the input Tensor x
with complete memory management.
Saves the result to result_diff
.
For a no-memory managed version see tanh_grad_plain
.
fn tanh_grad_plain(
&self,
x: &SharedTensor<F>,
x_diff: &SharedTensor<F>,
result: &SharedTensor<F>,
result_diff: &mut SharedTensor<F>
) -> Result<(), Error>
&self,
x: &SharedTensor<F>,
x_diff: &SharedTensor<F>,
result: &SharedTensor<F>,
result_diff: &mut SharedTensor<F>
) -> Result<(), Error>
Computes the gradient of tanh over the input Tensor x
without any memory management.
Saves the result to result_diff
.
Attention:
For a correct computation result, you need to manage the memory allocation and synchronization yourself.
For a memory managed version see tanh_grad
.