pub struct HistogramProto {
    pub min: f64,
    pub max: f64,
    pub num: f64,
    pub sum: f64,
    pub sum_squares: f64,
    pub bucket_limit: Vec<f64>,
    pub bucket: Vec<f64>,
}
Expand description

Serialization format for histogram module in tsl/lib/histogram/histogram.h

Fields§

§min: f64§max: f64§num: f64§sum: f64§sum_squares: f64§bucket_limit: Vec<f64>

Parallel arrays encoding the bucket boundaries and the bucket values. bucket(i) is the count for the bucket i. The range for a bucket is: i == 0: -DBL_MAX .. bucket_limit(0) i != 0: bucket_limit(i-1) .. bucket_limit(i)

§bucket: Vec<f64>

Implementations§

source§

impl HistogramProto

source

pub fn new<'a, L>(bucket_limit: L) -> Result<Self>where L: Into<Cow<'a, [f64]>>,

Create a histogram with bucket limits.

The bucket_limit must be an ordered sequence of finite values. Otherwise it returns an error. The range of each bucket is defined by

  • i == 0: f64::MIN..limit[0]
  • i > 0: limit[i-1]..limit[i]
source

pub fn tf_default() -> Self

Create a histogram with TensorFlow’s default bucket limits.

source

pub fn add_one(&mut self, value: f64)

Add one count to the bucket containing the value.

Panics

It panics if value is not finite.

source

pub fn add(&mut self, value: f64, count: f64)

Add counts to the bucket containing the value.

Panics

It panics if value is not finite, or count is not finite or not non-negative.

source

pub fn try_add_one(&mut self, value: f64) -> Result<()>

Add one count to the bucket containing the value.

value must be finite. Otherwise it returns an error.

source

pub fn try_add(&mut self, value: f64, count: f64) -> Result<()>

Add counts to the bucket containing the value.

value must be finite, and count must be finite and non-negative. Otherwise it returns an error.

source

pub fn try_iter(&self) -> Result<impl Iterator<Item = (f64, f64)> + '_>

Create an iterator of (limit, count).

If returns an error if the lenghs of bucket_limit and bucket differ.

source

pub fn iter(&self) -> impl Iterator<Item = (f64, f64)> + '_

Create an iterator of (limit, count).

Panics

It panics if the lenghs of bucket_limit and bucket differ.

source

pub fn try_from_iter<T, I>(iter: I) -> Result<Self, Error>where T: ToPrimitive, I: IntoIterator<Item = T>,

Create a histogram from an iterator of values, with TensorFlow’s default bucket limits.

Trait Implementations§

source§

impl Clone for HistogramProto

source§

fn clone(&self) -> HistogramProto

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for HistogramProto

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for HistogramProto

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for HistogramProto

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<A> FromIterator<A> for HistogramProtowhere A: ToPrimitive,

source§

fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl IntoHistogram for HistogramProto

source§

impl Message for HistogramProto

source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
source§

fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>where B: BufMut, Self: Sized,

Encodes the message to a buffer. Read more
source§

fn encode_to_vec(&self) -> Vec<u8, Global>where Self: Sized,

Encodes the message to a newly allocated buffer.
source§

fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>where B: BufMut, Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8, Global>where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
source§

fn decode<B>(buf: B) -> Result<Self, DecodeError>where B: Buf, Self: Default,

Decodes an instance of the message from a buffer. Read more
source§

fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>where B: Buf, Self: Default,

Decodes a length-delimited instance of the message from the buffer.
source§

fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>where B: Buf, Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
source§

fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>where B: Buf, Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
source§

impl PartialEq<HistogramProto> for HistogramProto

source§

fn eq(&self, other: &HistogramProto) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for HistogramProto

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for HistogramProto

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<R, P> ReadPrimitive<R> for Pwhere R: Read + ReadEndian<P>, P: Default,

source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,