Add the elu op. (#113)

This commit is contained in:
Laurent Mazare
2023-07-09 21:56:31 +01:00
committed by GitHub
parent ea5dfa69bc
commit 270997a055
8 changed files with 95 additions and 0 deletions

View File

@ -349,6 +349,16 @@ impl Tensor {
Ok(from_storage(storage, self.shape(), op, false))
}
pub fn elu(&self, alpha: f64) -> Result<Self> {
let storage = self.storage.elu(self.layout(), alpha)?;
let op = if self.track_op() {
Some(Op::Elu(self.clone(), alpha))
} else {
None
};
Ok(from_storage(storage, self.shape(), op, false))
}
fn check_dim(&self, dim: usize, op: &'static str) -> Result<()> {
if dim >= self.dims().len() {
Err(Error::DimOutOfRange {