burn_core/nn/
sigmoid.rs

1use crate as burn;
2
3use crate::module::Module;
4use crate::tensor::Tensor;
5use crate::tensor::backend::Backend;
6
7/// Applies the sigmoid function element-wise
8/// See also [sigmoid](burn::tensor::activation::sigmoid)
9#[derive(Module, Clone, Debug, Default)]
10pub struct Sigmoid;
11
12impl Sigmoid {
13    /// Create the module.
14    pub fn new() -> Self {
15        Self {}
16    }
17    /// Applies the forward pass on the input tensor.
18    ///
19    /// # Shapes
20    ///
21    /// - input: `[..., any]`
22    /// - output: `[..., any]`
23    pub fn forward<B: Backend, const D: usize>(&self, input: Tensor<B, D>) -> Tensor<B, D> {
24        crate::tensor::activation::sigmoid(input)
25    }
26}
27
28#[cfg(test)]
29mod tests {
30    use super::*;
31
32    #[test]
33    fn display() {
34        let layer = Sigmoid::new();
35
36        assert_eq!(alloc::format!("{layer}"), "Sigmoid");
37    }
38}