pub fn load_model<const IN: usize, const OUT: usize>(
path: impl AsRef<Path>,
) -> Result<NeuralNetwork<IN, OUT>, ModelError>Expand description
Reads a model from path, checking that its shape matches IN and OUT.
Files written by every earlier version of this library load too. Every layer is
checked against its neighbours, so a corrupted file is reported here rather than
panicking later in NeuralNetwork::feed_forward, and the file must end where the
model does.
§Errors
Returns ModelError::Io if the file cannot be read,
ModelError::UnrecognizedFormat if it is not a model,
ModelError::UnsupportedVersion if a newer version of this library wrote it,
ModelError::Malformed if it is truncated or corrupted,
ModelError::DimensionMismatch if the stored network does not fit
NeuralNetwork<IN, OUT>, and ModelError::EmptyNetwork or
ModelError::InconsistentLayer if its layers do not form a network at all.
§Example
let nn: NeuralNetwork<2, 1> = load_model("model.bin")?;