[−][src]Struct scholar::NeuralNet
A fully-connected neural network.
Methods
impl<A: Activation + Serialize + DeserializeOwned> NeuralNet<A>
[src]
pub fn new(node_counts: &[usize]) -> Self
[src]
Creates a new network with the given node configuration and activation.
Examples
use scholar::{NeuralNet, Sigmoid}; // Creates a neural network with two input nodes, // a single hidden layer with two nodes, and one output node let brain: NeuralNet<Sigmoid> = NeuralNet::new(&[2, 2, 1]);
Panics
This function panics if the number of layers
(i.e. the length of the given node_counts
slice)
is less than 2.
pub fn from_file(path: impl AsRef<Path>) -> Result<Self, LoadErr>
[src]
Creates a new network from a valid file.
Files are valid only if they were created using NeuralNet::save()
.
Examples
use scholar::{NeuralNet, Sigmoid}; let brain: NeuralNet<Sigmoid> = NeuralNet::from_file("brain.network")?;
pub fn train(
&mut self,
training_dataset: Dataset,
iterations: u64,
learning_rate: f64
)
[src]
&mut self,
training_dataset: Dataset,
iterations: u64,
learning_rate: f64
)
Trains the network on the given dataset for the given number of iterations.
Examples
use scholar::{Dataset, NeuralNet, Sigmoid}; let dataset = Dataset::from_csv("iris.csv", false, 4)?; let mut brain: NeuralNet<Sigmoid> = NeuralNet::new(&[4, 10, 10, 1]); brain.train(dataset, 10_000, 0.01);
pub fn test(&mut self, testing_dataset: Dataset) -> f64
[src]
Calculates the average cost of the network.
Examples
use scholar::{Dataset, NeuralNet, Sigmoid}; let dataset = Dataset::from_csv("iris.csv", false, 4)?; let (training_data, testing_data) = dataset.split(0.75); let mut brain: NeuralNet<Sigmoid> = NeuralNet::new(&[4, 10, 10, 1]); brain.train(training_data, 10_000, 0.01); let avg_cost = brain.test(testing_data); println!("Accuracy: {:.2}%", (1.0 - avg_cost) * 100.0);
pub fn save(&self, path: impl AsRef<Path>) -> Result<(), SaveErr>
[src]
Saves the network in a binary format to the specified path.
Examples
use scholar::{NeuralNet, Sigmoid}; let brain: NeuralNet<Sigmoid> = NeuralNet::new(&[2, 2, 1]); brain.save("brain")?;
pub fn guess(&mut self, inputs: &[f64]) -> Vec<f64>
[src]
Performs the feedforward algorithm on the given input slice, and returns the value of the output layer as a vector.
Examples
use scholar::{NeuralNet, Sigmoid}; let mut brain: NeuralNet<Sigmoid> = NeuralNet::new(&[3, 10, 2]); let result = brain.guess(&[1.0, 0.0, -0.5]); assert_eq!(result.len(), 2);
Panics
This method panics if the number of given input values is not equal to the number of nodes in the network's input layer.
Trait Implementations
impl<'de, A: Activation> Deserialize<'de> for NeuralNet<A>
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<A: Activation> Serialize for NeuralNet<A>
[src]
Auto Trait Implementations
impl<A> RefUnwindSafe for NeuralNet<A> where
A: RefUnwindSafe,
A: RefUnwindSafe,
impl<A> Send for NeuralNet<A> where
A: Send,
A: Send,
impl<A> Sync for NeuralNet<A> where
A: Sync,
A: Sync,
impl<A> Unpin for NeuralNet<A> where
A: Unpin,
A: Unpin,
impl<A> UnwindSafe for NeuralNet<A> where
A: UnwindSafe,
A: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,