Struct Network

Source
pub struct Network<const X: usize, const H: usize, const Y: usize> { /* private fields */ }
Expand description

Holds a neural network.

Implementations§

Source§

impl<const X: usize, const H: usize, const Y: usize> Network<X, H, Y>

Source

pub fn new( input_activation: Box<dyn Activation<H>>, output_activation: Box<dyn Activation<Y>>, learning_rate: f64, ) -> Self

Constructs a new neural network.

Source

pub fn add_hidden_layer(&mut self, activation: Box<dyn Activation<H>>)

Add a hidden layer.

Source

pub fn evaluate(&mut self, vector: Vector<X>) -> Vector<Y>

Evaluates a vector input.

Source

pub fn train_once(&mut self, input: Vector<X>, expected: Vector<Y>) -> f64

Train this network based on an input and an expected output.

Source

pub fn train_all(&mut self, dataset: &TrainingDataset<X, Y>) -> f64

Train this network based on a list of inputs and expected outputs.

Source

pub fn train(&mut self, dataset: &TrainingDataset<X, Y>, generations: usize)

Train this network based on a dataset for a given number of generations.

Auto Trait Implementations§

§

impl<const X: usize, const H: usize, const Y: usize> Freeze for Network<X, H, Y>

§

impl<const X: usize, const H: usize, const Y: usize> !RefUnwindSafe for Network<X, H, Y>

§

impl<const X: usize, const H: usize, const Y: usize> !Send for Network<X, H, Y>

§

impl<const X: usize, const H: usize, const Y: usize> !Sync for Network<X, H, Y>

§

impl<const X: usize, const H: usize, const Y: usize> Unpin for Network<X, H, Y>

§

impl<const X: usize, const H: usize, const Y: usize> !UnwindSafe for Network<X, H, Y>

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

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

Source§

fn vzip(self) -> V