pub struct MlpBuilder { /* private fields */ }Expand description
Builder for an Mlp.
Example:
use rust_mlp::{Activation, MlpBuilder};
let mlp = MlpBuilder::new(2)?
.add_layer(8, Activation::ReLU)?
.add_layer(1, Activation::Sigmoid)?
.build_with_seed(0)?;Implementations§
Source§impl MlpBuilder
impl MlpBuilder
Sourcepub fn new(input_dim: usize) -> Result<Self>
pub fn new(input_dim: usize) -> Result<Self>
Start building an MLP that accepts inputs of length input_dim.
Sourcepub fn from_sizes(sizes: &[usize], activations: &[Activation]) -> Result<Self>
pub fn from_sizes(sizes: &[usize], activations: &[Activation]) -> Result<Self>
Convenience constructor from a sizes list + activations.
sizes includes input and output dimensions, so its length must be at least 2.
activations must have length sizes.len() - 1.
Sourcepub fn add_layer(self, out_dim: usize, activation: Activation) -> Result<Self>
pub fn add_layer(self, out_dim: usize, activation: Activation) -> Result<Self>
Add a dense layer.
The layer will have out_dim outputs and uses activation.
Sourcepub fn build_with_seed(self, seed: u64) -> Result<Mlp>
pub fn build_with_seed(self, seed: u64) -> Result<Mlp>
Build using a deterministic seed.
Trait Implementations§
Source§impl Clone for MlpBuilder
impl Clone for MlpBuilder
Source§fn clone(&self) -> MlpBuilder
fn clone(&self) -> MlpBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MlpBuilder
impl RefUnwindSafe for MlpBuilder
impl Send for MlpBuilder
impl Sync for MlpBuilder
impl Unpin for MlpBuilder
impl UnwindSafe for MlpBuilder
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