-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8a7c54
commit 263add2
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use crate as burn; | ||
|
||
use crate::module::Module; | ||
use crate::tensor::backend::Backend; | ||
use crate::tensor::Tensor; | ||
|
||
/// Applies the tanh activation function element-wise | ||
/// See also [tanh](burn::tensor::activation::tanh) | ||
#[derive(Module, Clone, Debug, Default)] | ||
pub struct Tanh {} | ||
|
||
impl Tanh { | ||
/// Create the module. | ||
pub fn new() -> Self { | ||
Self {} | ||
} | ||
/// Applies the forward pass on the input tensor. | ||
/// | ||
/// # Shapes | ||
/// | ||
/// - input: `[..., any]` | ||
/// - output: `[..., any]` | ||
pub fn forward<B: Backend, const D: usize>(&self, input: Tensor<B, D>) -> Tensor<B, D> { | ||
crate::tensor::activation::tanh(input) | ||
} | ||
} |