pub struct TaskStatistics { /* private fields */ }Expand description
Running gradient statistics for one task.
Both moments are exact running means over every gradient the task has observed, which is what makes the derived embedding a property of the task rather than of the particular step it was sampled at.
Implementations§
Source§impl TaskStatistics
impl TaskStatistics
Sourcepub fn observe(&mut self, gradient: &[f64])
pub fn observe(&mut self, gradient: &[f64])
Fold one gradient into the running statistics.
A gradient of a different length than the ones seen so far restarts the statistics: it can only come from a task whose parameter vector changed shape, and averaging across shapes would produce a meaningless descriptor.
Sourcepub fn observations(&self) -> usize
pub fn observations(&self) -> usize
Number of gradients folded in.
Sourcepub fn mean_gradient(&self) -> &[f64]
pub fn mean_gradient(&self) -> &[f64]
Running mean gradient.
Sourcepub fn mean_squared_gradient(&self) -> &[f64]
pub fn mean_squared_gradient(&self) -> &[f64]
Running mean squared gradient.
Sourcepub fn embedding(&self, dim: usize) -> Vec<f64>
pub fn embedding(&self, dim: usize) -> Vec<f64>
Fixed-width task embedding derived from the statistics.
The descriptor is the whitened mean gradient
E[g_i] / sqrt(E[g_i^2] + eps): dividing the first moment by the square
root of the second is the diagonal natural-gradient direction, so a
coordinate that is merely noisy (large E[g^2], small E[g]) does not
dominate a coordinate that consistently pushes the same way. That vector
is then reduced to dim components by signed feature hashing
(Weinberger et al., “Feature Hashing for Large Scale Multitask
Learning”, ICML 2009), which preserves inner products in expectation
while making tasks of different parameter dimensionality comparable, and
finally normalized to unit length so cosine similarity is a plain dot
product.
A task whose gradients have averaged out to exactly zero has no direction; its embedding is all zeros and its similarity to everything is zero, which is the honest answer rather than an arbitrary one.
Trait Implementations§
Source§impl Clone for TaskStatistics
impl Clone for TaskStatistics
Source§fn clone(&self) -> TaskStatistics
fn clone(&self) -> TaskStatistics
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TaskStatistics
impl Debug for TaskStatistics
Source§impl Default for TaskStatistics
impl Default for TaskStatistics
Source§fn default() -> TaskStatistics
fn default() -> TaskStatistics
Auto Trait Implementations§
impl Freeze for TaskStatistics
impl RefUnwindSafe for TaskStatistics
impl Send for TaskStatistics
impl Sync for TaskStatistics
impl Unpin for TaskStatistics
impl UnsafeUnpin for TaskStatistics
impl UnwindSafe for TaskStatistics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.