Dense1d

Struct Dense1d 

Source
pub struct Dense1d { /* private fields */ }

Implementations§

Source§

impl Dense1d

Source

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 array
  • weights: 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
            );
Source

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 array
  • layer_size: number of nodes in the layer
  • activation_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§

Source§

impl Layer1d for Dense1d

Source§

fn pass(&self, input_array: Array1<f64>) -> (Array1<f64>, Array1<f64>)

Feeds forward the 1d array through the layer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V