pub struct EventWriter<W> { /* private fields */ }
Expand description

The event writer.

It provies write_scalar, write_image methods, etc.

It can be built from a writer using from_writer, or write a new file specified by path prefix using from_writer.

use anyhow::Result;
use std::time::SystemTime;
use tch::{kind::FLOAT_CPU, Tensor};
use tfrecord::EventWriter;

let mut writer = EventWriter::from_prefix("log_dir/myprefix-", "", Default::default()).unwrap();

// step = 0, scalar = 3.14
writer.write_scalar("my_scalar", 0, 3.14)?;

// step = 1, specified wall time, histogram of [1, 2, 3, 4]
writer.write_histogram("my_histogram", (1, SystemTime::now()), vec![1, 2, 3, 4])?;

// step = 2, specified raw UNIX time in nanoseconds, random tensor of shape [8, 3, 16, 16]
writer.write_tensor(
    "my_tensor",
    (2, 1.594449514712264e+18),
    Tensor::randn(&[8, 3, 16, 16], FLOAT_CPU),
)?;

Implementations

Build a writer writing events to a file.

Build a writer writing events to a file, which path is specified by a path prefix and file name suffix.

Build from a writer with Write trait.

Write a scalar summary.

Write a histogram summary.

Write a tensor summary.

Write an image summary.

Write a summary with multiple images.

Write an audio summary.

Write a custom event.

Flush this output stream.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.