hard_sigmoid
hard_sigmoid(x: &Tensor<T>) -> Result<Tensor<C>, TensorError>
Compute for all elements. A piece-wise linear approximation of the sigmoid function.
Parameters:
x
: Input values
Returns:
Tensor with type C
Examples:
use hpt::{ops::FloatUnaryOps, Tensor, error::TensorError};
fn main() -> Result<(), TensorError> {
let a = Tensor::<f32>::new([2.0]);
let b = a.hard_sigmoid()?;
println!("{}", b); // prints: 0.8333333
Ok(())
}
Backend Support
Backend | Supported |
---|---|
CPU | ✅ |
Cuda | ✅ |