Struct tfrecord::EventWriter[][src]

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

The event writer type.

The EventWriter is initialized by EventWriterInit. It provies a series write_* methods and write_*_async asynchronous analogues to append events to the file recognized by TensorBoard.

The typical usage call the EventWriterInit::from_prefix with the log directory to build a EventWriter.

#![cfg(feature = "full")]
use anyhow::Result;
use std::time::SystemTime;
use tch::{kind::FLOAT_CPU, Tensor};
use tfrecord::EventWriterInit;

fn main() -> Result<()> {
    let mut writer = EventWriterInit::default()
        .from_prefix("log_dir/myprefix-", None)
        .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),
    )?;

    Ok(())
}

Implementations

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.

Write a scalar summary asynchronously.

Write a histogram summary asynchronously.

Write a tensor summary asynchronously.

Write an image summary asynchronously.

Write a summary with multiple images asynchronously.

Write an audio summary asynchronously.

Write a custom event asynchronously.

Flush this output stream asynchronously.

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

Performs the conversion.

Performs the conversion.

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)

recently added

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.