[][src]Struct neuro::models::Network

pub struct Network { /* fields omitted */ }

Structure representing a neural network.

Methods

impl Network[src]

pub fn new<L: 'static + Loss, O: 'static + Optimizer>(
    input_shape: Dim,
    loss_function: L,
    optimizer: O,
    regularizer: Option<Regularizer>
) -> Result<Network, Error>
[src]

Creates an empty neural network.

The input shape must be in the form [height, width, channel, 1]. Mini-batches are created along the fourth dimension.

pub fn add(&mut self, layer: Box<dyn Layer>)[src]

Adds a layer to the network.

pub fn fit<T: DataSet>(
    &mut self,
    data: &T,
    batch_size: u64,
    epochs: u64,
    print_loss: Option<u64>,
    metrics: Option<Vec<Metrics>>
)
[src]

Fits the neural network with the training data.

The training data are shuffled at the beginning of each epoch, before batches are created. The progress is printed at every print_loss epoch.

pub fn evaluate<T: DataSet>(&self, data: &T, metrics: Option<Vec<Metrics>>)[src]

Evaluates the model on the test set.

Arguments

  • data - The dataset containing the test data.
  • metrics - A vector containing the metrics that will be evaluated.

pub fn predict(&self, input: &Tensor) -> Tensor[src]

Computes the output of the network for the given input.

Multiple samples can be evaluated at once by stacking them along the fourth dimension of the tensor.

Return value

Tensor of the predicted output

pub fn predict_class(&self, input: &Tensor) -> Vec<(String, PrimitiveType)>[src]

Predicts the class for the input.

Multiple samples can be evaluated at once by stacking them along the fourth dimension of the tensor.

Return value

Vector of tuples containing the predicted class and the probability for each sample.

Panic

Panics if the model doesn't contain a classes dictionary.

pub fn save(&self, filename: &str) -> Result<(), Error>[src]

Saves the model in HDF5 format.

pub fn load(filename: &str) -> Result<Network, Error>[src]

Loads a model from a HDF5 file.

Trait Implementations

impl Display for Network[src]

Auto Trait Implementations

impl !RefUnwindSafe for Network

impl !Send for Network

impl !Sync for Network

impl Unpin for Network

impl !UnwindSafe for Network

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,