Skip to main content

Dense

Struct Dense 

Source
pub struct Dense<V, A, const IN: usize, const OUT: usize> { /* private fields */ }
Expand description

A fully connected layer: IN inputs (plus a bias) to OUT neurons with activation A, and the training state of every connection.

A layer is a building block for NeuralNetwork; on its own it only exposes its weights.

Implementations§

Source§

impl<V: Copy, A, const IN: usize, const OUT: usize> Dense<V, A, IN, OUT>

Source

pub fn weights(&self) -> [[V; OUT]; IN]

The weights: weights()[input][neuron].

Source

pub fn bias_weights(&self) -> [V; OUT]

The bias weights: bias_weights()[neuron].

Source

pub fn set_weights(&mut self, weights: &[[V; OUT]; IN])

Replace the weights, laid out as weights returns them. The training state (delta weights, gradients) is kept.

Source

pub fn set_bias_weights(&mut self, weights: &[V; OUT])

Replace the bias weights.

Source

pub fn outputs(&self) -> [V; OUT]

The neurons’ activations from the latest forward pass.

Source§

impl<V: Copy, A, const IN: usize, const OUT: usize> Dense<V, A, IN, OUT>

Source

pub fn to_inference(&self) -> InferenceDense<V, A, IN, OUT>

This layer’s weights as an InferenceDense.

Source

pub fn set_from(&mut self, from: &InferenceDense<V, A, IN, OUT>)

Load the weights of an InferenceDense of the same shape (the training state is left as it is).

Trait Implementations§

Source§

impl<V: Scalar, A, const IN: usize, const OUT: usize> Default for Dense<V, A, IN, OUT>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<V, A, const IN: usize, const OUT: usize> Freeze for Dense<V, A, IN, OUT>
where V: Freeze,

§

impl<V, A, const IN: usize, const OUT: usize> RefUnwindSafe for Dense<V, A, IN, OUT>
where V: RefUnwindSafe,

§

impl<V, A, const IN: usize, const OUT: usize> Send for Dense<V, A, IN, OUT>
where V: Send,

§

impl<V, A, const IN: usize, const OUT: usize> Sync for Dense<V, A, IN, OUT>
where V: Sync,

§

impl<V, A, const IN: usize, const OUT: usize> Unpin for Dense<V, A, IN, OUT>
where V: Unpin,

§

impl<V, A, const IN: usize, const OUT: usize> UnsafeUnpin for Dense<V, A, IN, OUT>
where V: UnsafeUnpin,

§

impl<V, A, const IN: usize, const OUT: usize> UnwindSafe for Dense<V, A, IN, OUT>
where V: 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.