pub struct FeatureMap {
pub channels: usize,
pub height: usize,
pub width: usize,
pub data: Vec<f32>,
}Expand description
An image-shaped buffer: channels, then rows, then columns, which is the layout every published checkpoint stores and every convolution reads.
Fields§
§channels: usize§height: usize§width: usize§data: Vec<f32>Implementations§
Source§impl FeatureMap
impl FeatureMap
Sourcepub fn new(channels: usize, height: usize, width: usize) -> Self
pub fn new(channels: usize, height: usize, width: usize) -> Self
A zeroed map of the given shape.
Sourcepub fn from_vec(
channels: usize,
height: usize,
width: usize,
data: Vec<f32>,
) -> Result<Self, NetworkError>
pub fn from_vec( channels: usize, height: usize, width: usize, data: Vec<f32>, ) -> Result<Self, NetworkError>
Wraps data that is already in channel-height-width order.
Sourcepub fn to_tokens(&self) -> Matrix
pub fn to_tokens(&self) -> Matrix
The map as a [pixels, channels] matrix, which is the shape attention
and a linear layer want.
Sourcepub fn from_tokens(
tokens: &Matrix,
height: usize,
width: usize,
) -> Result<Self, NetworkError>
pub fn from_tokens( tokens: &Matrix, height: usize, width: usize, ) -> Result<Self, NetworkError>
The reverse of FeatureMap::to_tokens.
Trait Implementations§
Source§impl Clone for FeatureMap
impl Clone for FeatureMap
Source§impl Debug for FeatureMap
impl Debug for FeatureMap
Source§impl PartialEq for FeatureMap
impl PartialEq for FeatureMap
impl StructuralPartialEq for FeatureMap
Auto Trait Implementations§
impl Freeze for FeatureMap
impl RefUnwindSafe for FeatureMap
impl Send for FeatureMap
impl Sync for FeatureMap
impl Unpin for FeatureMap
impl UnsafeUnpin for FeatureMap
impl UnwindSafe for FeatureMap
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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 more