SummaryWriter

Struct SummaryWriter 

Source
pub struct SummaryWriter { /* private fields */ }

Implementations§

Source§

impl SummaryWriter

Source

pub fn new<P: AsRef<Path>>(logdir: P) -> SummaryWriter

Examples found in repository?
examples/draw_image.rs (line 6)
4pub fn main() {
5
6    let mut writer = SummaryWriter::new(&("./logdir".to_string()));
7
8    let stop_image = "./examples/stop.jpg";
9    let img = open(stop_image).expect("");
10    let img = img.into_rgb8();
11    let (width, height) = img.dimensions();
12
13    
14    writer.add_image(&"test_image".to_string(), &img.into_raw()[..], &vec![3, width as usize, height as usize][..], 12);
15    writer.flush();
16}
More examples
Hide additional examples
examples/draw_graph.rs (line 14)
13pub fn main() {
14    let mut writer = SummaryWriter::new(&("./logdir".to_string()));
15
16    let mut node1 = NodeDef::new();
17    node1.set_name("node1".to_string());
18    node1.set_op("op1".to_string());
19    
20    let inputs = RepeatedField::from(vec![]);
21    node1.set_input(inputs);
22    
23    let mut attrs = HashMap::new();
24    let mut v1 = AttrValue::new();
25    v1.set_i(16);
26    attrs.insert("attr1".to_string(), v1);
27    node1.set_attr(attrs);
28
29    writer.add_graph(&[node1]);
30    
31    writer.flush();
32}
examples/draw_scalar.rs (line 5)
4pub fn main() {
5    let mut writer = SummaryWriter::new(&("./logdir".to_string()));
6
7    let name = "run1";
8    let mut scalar = 2.3;
9    let mut step = 12;    
10    for i in 0..2 {
11        println!("{}", i);
12        scalar += (i as f32)*0.1;
13        step += i;
14
15        writer.add_scalar(name, scalar, step);
16    }
17    writer.flush();
18
19    for n_iter in 0..100 {
20        let mut map = HashMap::new();
21        map.insert("xsinx".to_string(), (n_iter as f32) * (n_iter as f32).sin());
22        map.insert("xcosx".to_string(), (n_iter as f32) * (n_iter as f32).cos());
23        map.insert("arctanx".to_string(), (n_iter as f32).atan());
24        writer.add_scalars("data/scalar_group", &map, n_iter);
25    }
26    writer.flush();
27}
examples/draw_histo.rs (line 6)
4pub fn main() {
5
6    let mut writer = SummaryWriter::new(&("./logdir".to_string()));
7
8    let min = 1.001;
9    let max = 29.001;
10    let num = 435.;
11    let sum = 8555.435;
12    let sum_squares = 189242.110435;
13    let bucket_limits = [3.8009999999999997, 6.600999999999999, 9.400999999999998, 12.200999999999999, 15.001, 17.801, 20.601, 23.401, 26.201, 29.001];
14    let bucket_counts = [ 6., 15., 24., 33., 27., 48., 57., 66., 75., 84.];
15    
16    writer.add_histogram_raw("run1/histo1",
17                             min, max,
18                             num,
19                             sum, sum_squares,
20                             &bucket_limits, &bucket_counts,
21                             1
22    );
23
24    writer.add_histogram_raw("run1/histo1",
25                             min, max,
26                             num,
27                             sum, sum_squares,
28                             &bucket_limits, &bucket_counts,
29                             2
30    );
31
32    writer.add_histogram_raw("run1/histo1",
33                             min, max,
34                             num,
35                             sum, sum_squares,
36                             &bucket_limits, &bucket_counts,
37                             3
38    );
39    writer.flush();
40}
Source

pub fn add_hparams(&mut self)

Source

pub fn add_scalar(&mut self, tag: &str, scalar_value: f32, step: usize)

Examples found in repository?
examples/draw_scalar.rs (line 15)
4pub fn main() {
5    let mut writer = SummaryWriter::new(&("./logdir".to_string()));
6
7    let name = "run1";
8    let mut scalar = 2.3;
9    let mut step = 12;    
10    for i in 0..2 {
11        println!("{}", i);
12        scalar += (i as f32)*0.1;
13        step += i;
14
15        writer.add_scalar(name, scalar, step);
16    }
17    writer.flush();
18
19    for n_iter in 0..100 {
20        let mut map = HashMap::new();
21        map.insert("xsinx".to_string(), (n_iter as f32) * (n_iter as f32).sin());
22        map.insert("xcosx".to_string(), (n_iter as f32) * (n_iter as f32).cos());
23        map.insert("arctanx".to_string(), (n_iter as f32).atan());
24        writer.add_scalars("data/scalar_group", &map, n_iter);
25    }
26    writer.flush();
27}
Source

pub fn add_scalars( &mut self, main_tag: &str, tag_scalar: &HashMap<String, f32>, step: usize, )

Examples found in repository?
examples/draw_scalar.rs (line 24)
4pub fn main() {
5    let mut writer = SummaryWriter::new(&("./logdir".to_string()));
6
7    let name = "run1";
8    let mut scalar = 2.3;
9    let mut step = 12;    
10    for i in 0..2 {
11        println!("{}", i);
12        scalar += (i as f32)*0.1;
13        step += i;
14
15        writer.add_scalar(name, scalar, step);
16    }
17    writer.flush();
18
19    for n_iter in 0..100 {
20        let mut map = HashMap::new();
21        map.insert("xsinx".to_string(), (n_iter as f32) * (n_iter as f32).sin());
22        map.insert("xcosx".to_string(), (n_iter as f32) * (n_iter as f32).cos());
23        map.insert("arctanx".to_string(), (n_iter as f32).atan());
24        writer.add_scalars("data/scalar_group", &map, n_iter);
25    }
26    writer.flush();
27}
Source

pub fn export_scalars_to_json(&self)

Source

pub fn add_histogram(&mut self)

Source

pub fn add_histogram_raw( &mut self, tag: &str, min: f64, max: f64, num: f64, sum: f64, sum_squares: f64, bucket_limits: &[f64], bucket_counts: &[f64], step: usize, )

Examples found in repository?
examples/draw_histo.rs (lines 16-22)
4pub fn main() {
5
6    let mut writer = SummaryWriter::new(&("./logdir".to_string()));
7
8    let min = 1.001;
9    let max = 29.001;
10    let num = 435.;
11    let sum = 8555.435;
12    let sum_squares = 189242.110435;
13    let bucket_limits = [3.8009999999999997, 6.600999999999999, 9.400999999999998, 12.200999999999999, 15.001, 17.801, 20.601, 23.401, 26.201, 29.001];
14    let bucket_counts = [ 6., 15., 24., 33., 27., 48., 57., 66., 75., 84.];
15    
16    writer.add_histogram_raw("run1/histo1",
17                             min, max,
18                             num,
19                             sum, sum_squares,
20                             &bucket_limits, &bucket_counts,
21                             1
22    );
23
24    writer.add_histogram_raw("run1/histo1",
25                             min, max,
26                             num,
27                             sum, sum_squares,
28                             &bucket_limits, &bucket_counts,
29                             2
30    );
31
32    writer.add_histogram_raw("run1/histo1",
33                             min, max,
34                             num,
35                             sum, sum_squares,
36                             &bucket_limits, &bucket_counts,
37                             3
38    );
39    writer.flush();
40}
Source

pub fn add_image(&mut self, tag: &str, data: &[u8], dim: &[usize], step: usize)

Examples found in repository?
examples/draw_image.rs (line 14)
4pub fn main() {
5
6    let mut writer = SummaryWriter::new(&("./logdir".to_string()));
7
8    let stop_image = "./examples/stop.jpg";
9    let img = open(stop_image).expect("");
10    let img = img.into_rgb8();
11    let (width, height) = img.dimensions();
12
13    
14    writer.add_image(&"test_image".to_string(), &img.into_raw()[..], &vec![3, width as usize, height as usize][..], 12);
15    writer.flush();
16}
Source

pub fn add_images(&mut self)

Source

pub fn add_image_with_boxes(&mut self)

Source

pub fn add_figure(&mut self)

Source

pub fn add_video(&mut self)

Source

pub fn add_audio(&mut self)

Source

pub fn add_text(&mut self)

Source

pub fn add_onnx_graph(&mut self)

Source

pub fn add_openvino_graph(&mut self)

Source

pub fn add_graph(&mut self, node_list: &[NodeDef])

Examples found in repository?
examples/draw_graph.rs (line 29)
13pub fn main() {
14    let mut writer = SummaryWriter::new(&("./logdir".to_string()));
15
16    let mut node1 = NodeDef::new();
17    node1.set_name("node1".to_string());
18    node1.set_op("op1".to_string());
19    
20    let inputs = RepeatedField::from(vec![]);
21    node1.set_input(inputs);
22    
23    let mut attrs = HashMap::new();
24    let mut v1 = AttrValue::new();
25    v1.set_i(16);
26    attrs.insert("attr1".to_string(), v1);
27    node1.set_attr(attrs);
28
29    writer.add_graph(&[node1]);
30    
31    writer.flush();
32}
Source

pub fn add_embedding(&mut self)

Source

pub fn add_pr_curve(&mut self)

Source

pub fn add_pr_curve_raw(&mut self)

Source

pub fn add_custom_scalars_multilinechart(&mut self)

Source

pub fn add_custom_scalars_marginchart(&mut self)

Source

pub fn add_custom_scalars(&mut self)

Source

pub fn add_mesh(&mut self)

Source

pub fn flush(&mut self)

Examples found in repository?
examples/draw_image.rs (line 15)
4pub fn main() {
5
6    let mut writer = SummaryWriter::new(&("./logdir".to_string()));
7
8    let stop_image = "./examples/stop.jpg";
9    let img = open(stop_image).expect("");
10    let img = img.into_rgb8();
11    let (width, height) = img.dimensions();
12
13    
14    writer.add_image(&"test_image".to_string(), &img.into_raw()[..], &vec![3, width as usize, height as usize][..], 12);
15    writer.flush();
16}
More examples
Hide additional examples
examples/draw_graph.rs (line 31)
13pub fn main() {
14    let mut writer = SummaryWriter::new(&("./logdir".to_string()));
15
16    let mut node1 = NodeDef::new();
17    node1.set_name("node1".to_string());
18    node1.set_op("op1".to_string());
19    
20    let inputs = RepeatedField::from(vec![]);
21    node1.set_input(inputs);
22    
23    let mut attrs = HashMap::new();
24    let mut v1 = AttrValue::new();
25    v1.set_i(16);
26    attrs.insert("attr1".to_string(), v1);
27    node1.set_attr(attrs);
28
29    writer.add_graph(&[node1]);
30    
31    writer.flush();
32}
examples/draw_scalar.rs (line 17)
4pub fn main() {
5    let mut writer = SummaryWriter::new(&("./logdir".to_string()));
6
7    let name = "run1";
8    let mut scalar = 2.3;
9    let mut step = 12;    
10    for i in 0..2 {
11        println!("{}", i);
12        scalar += (i as f32)*0.1;
13        step += i;
14
15        writer.add_scalar(name, scalar, step);
16    }
17    writer.flush();
18
19    for n_iter in 0..100 {
20        let mut map = HashMap::new();
21        map.insert("xsinx".to_string(), (n_iter as f32) * (n_iter as f32).sin());
22        map.insert("xcosx".to_string(), (n_iter as f32) * (n_iter as f32).cos());
23        map.insert("arctanx".to_string(), (n_iter as f32).atan());
24        writer.add_scalars("data/scalar_group", &map, n_iter);
25    }
26    writer.flush();
27}
examples/draw_histo.rs (line 39)
4pub fn main() {
5
6    let mut writer = SummaryWriter::new(&("./logdir".to_string()));
7
8    let min = 1.001;
9    let max = 29.001;
10    let num = 435.;
11    let sum = 8555.435;
12    let sum_squares = 189242.110435;
13    let bucket_limits = [3.8009999999999997, 6.600999999999999, 9.400999999999998, 12.200999999999999, 15.001, 17.801, 20.601, 23.401, 26.201, 29.001];
14    let bucket_counts = [ 6., 15., 24., 33., 27., 48., 57., 66., 75., 84.];
15    
16    writer.add_histogram_raw("run1/histo1",
17                             min, max,
18                             num,
19                             sum, sum_squares,
20                             &bucket_limits, &bucket_counts,
21                             1
22    );
23
24    writer.add_histogram_raw("run1/histo1",
25                             min, max,
26                             num,
27                             sum, sum_squares,
28                             &bucket_limits, &bucket_counts,
29                             2
30    );
31
32    writer.add_histogram_raw("run1/histo1",
33                             min, max,
34                             num,
35                             sum, sum_squares,
36                             &bucket_limits, &bucket_counts,
37                             3
38    );
39    writer.flush();
40}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.