pub struct NeuralNetwork {
pub learning_rate: f32,
pub layer_sizes: Vec<u32>,
pub weights: Vec<Matrix>,
pub biases: Vec<Matrix>,
pub command_receiver: Option<Receiver<NNCommand>>,
pub command_sender: Option<Sender<NNCommand>>,
pub update_interval: usize,
}Expand description
A Neural Network, use this one for training and the other one for predicting
Fields§
§learning_rate: f32§layer_sizes: Vec<u32>§weights: Vec<Matrix>§biases: Vec<Matrix>§command_receiver: Option<Receiver<NNCommand>>§command_sender: Option<Sender<NNCommand>>§update_interval: usizeImplementations§
Source§impl NeuralNetwork
impl NeuralNetwork
pub fn new(layer_sizes: Vec<u32>) -> NeuralNetwork
Sourcepub fn train_batches(
&mut self,
input: Vec<Vec<f32>>,
target: Vec<Vec<f32>>,
batch_number: usize,
) -> usize
pub fn train_batches( &mut self, input: Vec<Vec<f32>>, target: Vec<Vec<f32>>, batch_number: usize, ) -> usize
One Epoch: Create a batch of n neural networks, and divide the training data for those n networks Let them train and then average the weights and biases of the networks Return the averaged weights and biases and then average the weights and bias correction over all the networks and apply them to the neural network Run each batch in a thread Returns the amount of correct predictions
Sourcepub fn train_epochs(
&mut self,
input: Vec<Vec<f32>>,
target: Vec<Vec<f32>>,
batch_number: usize,
epochs: usize,
)
pub fn train_epochs( &mut self, input: Vec<Vec<f32>>, target: Vec<Vec<f32>>, batch_number: usize, epochs: usize, )
Train the neural network with the given input and target for x epochs
Sourcepub fn save_weights_biases(&self, file_name: String)
pub fn save_weights_biases(&self, file_name: String)
Save weights and biases to a file in the current directory called
Sourcepub fn load_from_save(path: &str) -> Self
pub fn load_from_save(path: &str) -> Self
Load weights and biases from a file in the current directory todo: tests this
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NeuralNetwork
impl RefUnwindSafe for NeuralNetwork
impl Send for NeuralNetwork
impl !Sync for NeuralNetwork
impl Unpin for NeuralNetwork
impl UnwindSafe for NeuralNetwork
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more