Comment on page
nn.relu
fn relu(tensor: @Tensor<T>) -> Tensor<T>;
Applies the rectified linear unit function element-wise
tensor
(@Tensor<T>
) - The input tensor.
A
Tensor<T>
with the same shape as the input tensor.use array::{ArrayTrait, SpanTrait};
use orion::operators::tensor::{TensorTrait, Tensor, I32Tensor};
use orion::operators::nn::{NNTrait, I32NN};
use orion::numbers::{i32, IntegerTrait};
fn relu_example() -> Tensor<i32> {
let tensor = TensorTrait::<i32>::new(
shape: array![2, 2].span(),
data: array![
IntegerTrait::new(1, false),
IntegerTrait::new(2, false),
IntegerTrait::new(1, true),
IntegerTrait::new(2, true),
]
.span(),
);
return NNTrait::relu(@tensor);
}
>>> [[1,2],[0,0]]
Last modified 2mo ago