Struct ducky_learn::layers::Dense1d
source · pub struct Dense1d { /* private fields */ }Implementations§
source§impl Dense1d
impl Dense1d
sourcepub fn from(
activation: fn(_: Array1<f64>) -> Array1<f64>,
deriv_activation: fn(_: Array1<f64>) -> Array1<f64>,
weights: Array2<f64>,
bias: Array1<f64>
) -> Self
pub fn from( activation: fn(_: Array1<f64>) -> Array1<f64>, deriv_activation: fn(_: Array1<f64>) -> Array1<f64>, weights: Array2<f64>, bias: Array1<f64> ) -> Self
Create Dense1d layer with full control over every part of the layer
Arguments
activation: Activation function of whole 1d arrayweights: 2d array that has to be of shape( output, input )bias: 1d array of basis that has to be the size of the output
returns: Dense1d
Examples
use ducky_learn::layers::*;
use ndarray::{arr1, arr2};
let layer = Dense1d::from(
|x| x, // Activation function that is does nothing
|x| x.map(|i| 1f64), // Derivative of Activation function
arr2(&[[1., 1.], [1., 1.]]), // 2x2 array
arr1(&[1., 1.]) // len 2
);sourcepub fn new(
input_size: usize,
layer_size: usize,
activation_fn: fn(_: Array1<f64>) -> Array1<f64>,
deriv_activation_fn: fn(_: Array1<f64>) -> Array1<f64>
) -> Self
pub fn new( input_size: usize, layer_size: usize, activation_fn: fn(_: Array1<f64>) -> Array1<f64>, deriv_activation_fn: fn(_: Array1<f64>) -> Array1<f64> ) -> Self
Create randomly set weights and bias’s for the dense1d layer. Creates weights and bias’s using a normal distribution from -1. -> 1.
Arguments
input_size: size of input arraylayer_size: number of nodes in the layeractivation_fn: activation function for the layer
returns: Dense1d
Examples
use ducky_learn::layers::*;
use ndarray::{arr1, arr2};
let layer = Dense1d::new(5, 10, |x| x, |x| x);
let input_array = arr1(&[
1., 1., 1., 1., 1.
]);
layer.pass(input_array);Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Dense1d
impl Send for Dense1d
impl Sync for Dense1d
impl Unpin for Dense1d
impl UnwindSafe for Dense1d
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