Skip to main content

Flatten

Struct Flatten 

Source
pub struct Flatten<D: Dtype, IT, OT> { /* private fields */ }
Expand description

Flatten layer: collapses all spatial dimensions into a single feature vector.

Input shape: [N, C, H, W] (rank 4) Output shape: [N, C * H * W] (rank 2)

Type parameters:

  • D — element dtype
  • IT — input tensor type (rank 4: [N, C, H, W])
  • OT — output tensor type (rank 2: [N, C*H*W])

Tensor bounds are on impls, not the struct, so SymTensor can have its own Layer impl without a coherence conflict.

Implementations§

Source§

impl<D: Dtype, IT, OT> Flatten<D, IT, OT>

Source

pub fn new() -> Self

Creates a new Flatten layer.

Trait Implementations§

Source§

impl<D: Dtype, IT, OT> Default for Flatten<D, IT, OT>

Source§

fn default() -> Self

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

impl<D: Dtype, IT: Tensor<D, 4> + EagerTensor, OT: Tensor<D, 2>> Layer<IT> for Flatten<D, IT, OT>

Source§

type Output = OT

This layer’s output type.
Source§

fn call(&self, _input: IT) -> Self::Output

Applies this layer to input.
Source§

impl<D: Dtype> Layer<SymTensor> for Flatten<D, SymTensor, SymTensor>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.

Auto Trait Implementations§

§

impl<D, IT, OT> Freeze for Flatten<D, IT, OT>

§

impl<D, IT, OT> RefUnwindSafe for Flatten<D, IT, OT>

§

impl<D, IT, OT> Send for Flatten<D, IT, OT>
where D: Send, IT: Send, OT: Send,

§

impl<D, IT, OT> Sync for Flatten<D, IT, OT>
where D: Sync, IT: Sync, OT: Sync,

§

impl<D, IT, OT> Unpin for Flatten<D, IT, OT>
where D: Unpin, IT: Unpin, OT: Unpin,

§

impl<D, IT, OT> UnsafeUnpin for Flatten<D, IT, OT>

§

impl<D, IT, OT> UnwindSafe for Flatten<D, IT, OT>
where D: UnwindSafe, IT: UnwindSafe, OT: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

Source§

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.