nn

Struct NN

Source
pub struct NN { /* private fields */ }
Expand description

Neural network

Implementations§

Source§

impl NN

Source

pub fn new(layers_sizes: &[u32]) -> NN

Each number in the layers_sizes parameter specifies a layer in the network. The number itself is the number of nodes in that layer. The first number is the input layer, the last number is the output layer, and all numbers between the first and last are hidden layers. There must be at least two layers in the network.

Source

pub fn run(&self, inputs: &[f64]) -> Vec<f64>

Runs the network on an input and returns a vector of the results. The number of f64s in the input must be the same as the number of input nodes in the network. The length of the results vector will be the number of nodes in the output layer of the network.

Source

pub fn train<'b>( &'b mut self, examples: &'b [(Vec<f64>, Vec<f64>)], ) -> Trainer<'_, '_>

Takes in vector of examples and returns a Trainer struct that is used to specify options that dictate how the training should proceed. No actual training will occur until the go() method on the Trainer struct is called.

Source

pub fn to_json(&self) -> String

Encodes the network as a JSON string.

Source

pub fn from_json(encoded: &str) -> NN

Builds a new network from a JSON string.

Trait Implementations§

Source§

impl Clone for NN

Source§

fn clone(&self) -> NN

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NN

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Decodable for NN

Source§

fn decode<__D: Decoder>(d: &mut __D) -> Result<NN, __D::Error>

Deserialize a value using a Decoder.
Source§

impl Encodable for NN

Source§

fn encode<__S: Encoder>(&self, s: &mut __S) -> Result<(), __S::Error>

Serialize a value using an Encoder.

Auto Trait Implementations§

§

impl Freeze for NN

§

impl RefUnwindSafe for NN

§

impl Send for NN

§

impl Sync for NN

§

impl Unpin for NN

§

impl UnwindSafe for NN

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.