# Crate prophet [−] [src]

A neural net implementation focused on sequential performance.

The API works as follows:

- The general shape of neural networks is defined with a topology.
- Topologies can be consumed by a mentor to train it with given training samples.
- After successful training the neural net's
`predict`

method can be used to predict data.

Currently this library only supports supervised learning and fully connected layers.

# Example

The code below demonstrates how to train a neural net to be a logical-OR operator.

#[macro_use] extern crate prophet; use prophet::prelude::*; use Activation::Tanh; let (t, f) = (1.0, -1.0); // static samples are easily generated with this macro! let train_samples = samples![ [f, f] => f, // ⊥ ∧ ⊥ → ⊥ [f, t] => t, // ⊥ ∧ ⊤ → ⊤ [t, f] => t, // ⊤ ∧ ⊥ → ⊤ [t, t] => t // ⊤ ∧ ⊤ → ⊤ ]; // create the topology for our neural network let top = Topology::input(2) // has two input neurons .layer(3, Tanh) // with 3 neurons in the first hidden layer .layer(2, Tanh) // and 2 neurons in the second hidden layer .output(1, Tanh); // and 1 neuron in the output layer let mut net = top.train(train_samples) .learn_rate(0.25) // use the given learn rate .learn_momentum(0.6) // use the given learn momentum .log_config(LogConfig::Iterations(100)) // log state every 100 iterations .scheduling(Scheduling::Random) // use random sample scheduling .criterion(Criterion::RecentMSE(0.05)) // train until the recent MSE is below 0.05 .go() // start the training session .unwrap(); // be ashamed to unwrap a Result // PROFIT! now you can use the neural network to predict data! assert_eq!(net.predict(&[f, f])[0].round(), f); assert_eq!(net.predict(&[f, t])[0].round(), t);

# Example

A more minimalistic example code for the same logical-OR operation:

// create the topology for our neural network let mut net = Topology::input(2) // has two input neurons .layer(3, Tanh) // with 3 neurons in the first hidden layer .layer(2, Tanh) // and 2 neurons in the second hidden layer .output(1, Tanh) // and 1 neuron in the output layer // train it for the given samples .train(samples![ [f, f] => f, // ⊥ ∧ ⊥ → ⊥ [f, t] => t, // ⊥ ∧ ⊤ → ⊤ [t, f] => t, // ⊤ ∧ ⊥ → ⊤ [t, t] => t // ⊤ ∧ ⊤ → ⊤ ]) .go() // start the training session .unwrap(); // and unwrap the Result assert_eq!(net.predict(&[f, f])[0].round(), f); assert_eq!(net.predict(&[f, t])[0].round(), t);

## Modules

prelude |
The prophet prelude publicly imports all propet modules the user needs in order to create, train and use neural networks. |

topology |
Provides operations, data structures and error definitions for Disciple objects which form the basis for topologies of neural networks. |

## Macros

samples |
Creates a vector of samples. |

## Structs

Mentor |
Mentor follows the builder pattern to incrementally build properties for the training session and delay any expensive computations until the go routine is called. |

NeuralNet |
A neural net. |

Sample |
A sample used to train a disciple during supervised learning. |

SampleView |
A sample view used to train a disciple during supervised learning. |

## Enums

Activation |
Represents an activation function. |

Criterion |
Cirterias after which the learning process holds. |

ErrorKind |
Kinds of errors that may occure while using this crate. |

LogConfig |
Logging interval for logging stats during the learning process. |

Scheduling |
Sample scheduling strategy while learning. |

## Traits

Predict |
Types that can predict data based on a one-dimensional input data range. |

## Type Definitions

MentorBuilder |
A fresh mentor which is completely uninitialized, yet. |

Result |
Result type for procedures of this crate. |