stddev/stddev.rs
1use onnx_helpers::prelude::*;
2use onnx_pb::{save_model, tensor_proto::DataType};
3
4fn main() {
5 let mut graph = builder::Graph::new("stddev");
6 let x = graph.input("X").typed(DataType::Float).dim(1).dim(6).node();
7 let two = graph.constant("two", 2.0f32);
8 let std = (&x - x.mean(1, true)).abs().pow(two).mean(1, true).sqrt();
9 let graph = graph.outputs_typed(std.with_name("stddev"), DataType::Float);
10 let model = graph.model().build();
11 save_model("stddev.onnx", &model).unwrap();
12}