pub struct OutputLayer<A: Activation, Neurons: NL<Input>, Input: AL> { /* private fields */ }
Expand description
The final layer of a Network.
Implementations§
Source§impl<A: Activation, Neurons: NL<Input>, Input: AL> OutputLayer<A, Neurons, Input>
impl<A: Activation, Neurons: NL<Input>, Input: AL> OutputLayer<A, Neurons, Input>
Trait Implementations§
Source§impl<A: Clone + Activation, Neurons: Clone + NL<Input>, Input: Clone + AL> Clone for OutputLayer<A, Neurons, Input>
impl<A: Clone + Activation, Neurons: Clone + NL<Input>, Input: Clone + AL> Clone for OutputLayer<A, Neurons, Input>
Source§fn clone(&self) -> OutputLayer<A, Neurons, Input>
fn clone(&self) -> OutputLayer<A, Neurons, Input>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<A: Debug + Activation, Neurons: Debug + NL<Input>, Input: Debug + AL> Debug for OutputLayer<A, Neurons, Input>
impl<A: Debug + Activation, Neurons: Debug + NL<Input>, Input: Debug + AL> Debug for OutputLayer<A, Neurons, Input>
Source§impl<'de, A: Activation, Neurons, Input> Deserialize<'de> for OutputLayer<A, Neurons, Input>
impl<'de, A: Activation, Neurons, Input> Deserialize<'de> for OutputLayer<A, Neurons, Input>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<A: Activation, Input: AL, Neurons: NL<Input>> Layer<Input, Neurons, Neurons, A> for OutputLayer<A, Neurons, Input>
impl<A: Activation, Input: AL, Neurons: NL<Input>> Layer<Input, Neurons, Neurons, A> for OutputLayer<A, Neurons, Input>
Source§fn calculate(
&self,
inputs: &GenericArray<f32, Input>,
) -> GenericArray<f32, Neurons>
fn calculate( &self, inputs: &GenericArray<f32, Input>, ) -> GenericArray<f32, Neurons>
runs the inputs through this and lower layers, resulting in the output
Source§fn step(
&self,
inputs: &GenericArray<f32, Neurons>,
) -> GenericArray<f32, Neurons>
fn step( &self, inputs: &GenericArray<f32, Neurons>, ) -> GenericArray<f32, Neurons>
runs only this layers calculation, not recursing to deeper layers
Source§fn weight(
&self,
inputs: &GenericArray<f32, Input>,
) -> GenericArray<f32, Neurons>
fn weight( &self, inputs: &GenericArray<f32, Input>, ) -> GenericArray<f32, Neurons>
reduces the inputs to a single input per neuron using the weights.
i.e. calculates the input to the activation functions for the neurons
Source§fn _get_error(
&mut self,
output: GenericArray<f32, Neurons>,
correct_output: &GenericArray<f32, Neurons>,
_speed: f32,
) -> (GenericArray<f32, Neurons>, GenericArray<f32, Neurons>)
fn _get_error( &mut self, output: GenericArray<f32, Neurons>, correct_output: &GenericArray<f32, Neurons>, _speed: f32, ) -> (GenericArray<f32, Neurons>, GenericArray<f32, Neurons>)
gets this layers error, either by comparing with correct output or by calling lower layers
Source§fn _apply_deltas(
&mut self,
deltas: GenericArray<f32, Neurons>,
inputs: &GenericArray<f32, Input>,
speed: f32,
)
fn _apply_deltas( &mut self, deltas: GenericArray<f32, Neurons>, inputs: &GenericArray<f32, Input>, speed: f32, )
modifies own weights by given deltas
Source§fn _pre_error(
&self,
deltas: &GenericArray<f32, Neurons>,
) -> GenericArray<f32, Input>
fn _pre_error( &self, deltas: &GenericArray<f32, Neurons>, ) -> GenericArray<f32, Input>
calculates the previous layers errors from this layers errors and weights
Source§fn backprop(
&mut self,
input: &GenericArray<f32, Input>,
correct_output: &GenericArray<f32, FinalOut>,
speed: f32,
) -> (GenericArray<f32, Input>, GenericArray<f32, FinalOut>)
fn backprop( &mut self, input: &GenericArray<f32, Input>, correct_output: &GenericArray<f32, FinalOut>, speed: f32, ) -> (GenericArray<f32, Input>, GenericArray<f32, FinalOut>)
pass in the input and the expected output. calculates the error for each neuron
and corrects itself
speed should be 0..1 and modifies how strongly the weights are adjusted
Source§fn _weight_errors(
&self,
error: GenericArray<f32, Neurons>,
weighted_inputs: &GenericArray<f32, Neurons>,
) -> GenericArray<f32, Neurons>
fn _weight_errors( &self, error: GenericArray<f32, Neurons>, weighted_inputs: &GenericArray<f32, Neurons>, ) -> GenericArray<f32, Neurons>
weights errors relative to activation. gets called by backprop, don’t call this manually
fn teach<F: FnMut(usize, f32), I: IntoIterator<Item = (GenericArray<f32, Input>, GenericArray<f32, FinalOut>)>>( &mut self, lesson: I, iterations: usize, callback: F, )
Source§impl<A: Activation, Neurons, Input> Serialize for OutputLayer<A, Neurons, Input>
impl<A: Activation, Neurons, Input> Serialize for OutputLayer<A, Neurons, Input>
Auto Trait Implementations§
impl<A, Neurons, Input> Freeze for OutputLayer<A, Neurons, Input>where
<Neurons as ArrayLength<GenericArray<f32, Input>>>::ArrayType: Freeze,
<Neurons as ArrayLength<f32>>::ArrayType: Freeze,
impl<A, Neurons, Input> RefUnwindSafe for OutputLayer<A, Neurons, Input>where
<Neurons as ArrayLength<GenericArray<f32, Input>>>::ArrayType: RefUnwindSafe,
<Neurons as ArrayLength<f32>>::ArrayType: RefUnwindSafe,
A: RefUnwindSafe,
impl<A, Neurons, Input> Send for OutputLayer<A, Neurons, Input>where
A: Send,
impl<A, Neurons, Input> Sync for OutputLayer<A, Neurons, Input>where
A: Sync,
impl<A, Neurons, Input> Unpin for OutputLayer<A, Neurons, Input>where
<Neurons as ArrayLength<GenericArray<f32, Input>>>::ArrayType: Unpin,
<Neurons as ArrayLength<f32>>::ArrayType: Unpin,
A: Unpin,
impl<A, Neurons, Input> UnwindSafe for OutputLayer<A, Neurons, Input>where
<Neurons as ArrayLength<GenericArray<f32, Input>>>::ArrayType: UnwindSafe,
<Neurons as ArrayLength<f32>>::ArrayType: UnwindSafe,
A: UnwindSafe,
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