SurfaceNetwork

Struct SurfaceNetwork 

Source
pub struct SurfaceNetwork<T = f32> { /* private fields */ }
Expand description

A neural network capable of dynamic configuration. Essentially, each network is designed to materialize the surface of a 2-simplex (triad) using barycentric coordinates to define three critical points. These critical points define the minimum number of hidden layers within the network and serve as goalposts that guide the learning process. The remaining points continue this trend, simply mapping each extra hidden layer to another position within space. The verticies of the simplex are used to inform the input layer and in finding the centroid of the facet. The centroid defines the output layer of the facet, serving as the final piece in a pseudo sink-source dyanamic.

Implementations§

Source§

impl<A> SurfaceNetwork<A>

Source

pub fn add_critical_point(&mut self, kind: PointKind) -> &mut Self
where A: Float,

Add a new critical point to configure part of the network’s hidden layer

Source

pub fn predict<X, Y>(&self, input: &X) -> Result<Y, NeuralError>
where SurfaceModel<A>: Predict<X, Output = Y>,

forward propogate the given input through the network

Source

pub fn train<X, Y, Z>( &mut self, input: &X, expected: &Y, ) -> Result<Z, NeuralError>
where A: Float + FromPrimitive + NumAssign + ScalarOperand + FftNum, SurfaceModel<A>: Train<X, Y, Output = Z>,

perform a single backpropagation step on qualifing datasets

Source

pub fn get_centroid(&self) -> Option<[A; 2]>
where A: Float + FromPrimitive,

get the position of the centroid w.r.t the headspace

Source

pub fn get_position(&self, cp_index: usize) -> Option<[A; 3]>
where A: Copy + Num,

returns the position of a particular hidden layer w.r.t. the current headspace

Source

pub fn init(self) -> Self
where SurfaceModel<A>: Init,

initialize the network

Source

pub fn init_inplace(&mut self) -> &mut Self

initialize the network in-place

Source

pub fn predict_with_confidence<X, Y>( &self, input: &X, ) -> Result<(Y, <SurfaceModel<A> as PredictWithConfidence<X>>::Confidence), NeuralError>
where SurfaceModel<A>: PredictWithConfidence<X, Output = Y>,

returns the model’s prediction with a confidence value

Source

pub fn reconfigure(&mut self, next: Triad)
where A: Float,

reconfigure the network with respect to the given triad; the method is typically called after applying a transformation to the headspace

Source

pub fn transfer_knowledge_from(&mut self, other: &Self, adaptation_rate: A)
where A: Copy + PartialOrd + Num + Signed,

Transfer knowledge from another surface network

Source

pub fn transform(&mut self, transform: LPR) -> SurfaceResult<()>
where A: Float,

applies the given LPR transformation to the headspace of the network before applying the neccessary adjusments to the architecture.

Source

pub fn walk<I>(&mut self, iter: I) -> SurfaceResult<()>
where A: Float, I: IntoIterator<Item = LPR>,

Walk the network through a series of transformations

Source§

impl<T> SurfaceNetwork<T>

Source

pub fn new(headspace: Triad) -> Self
where T: Float + FromPrimitive,

Create a new surface network for the given triad

Source

pub const fn headspace(&self) -> Triad

returns an immutable reference to the network’s headspace

Source

pub fn headspace_mut(&mut self) -> &mut Triad

returns a mutable reference to the network’s headspace

Source

pub const fn model(&self) -> &SurfaceModel<T>

returns an immutable reference to the network’s surface

Source

pub fn model_mut(&mut self) -> &mut SurfaceModel<T>

returns a mutable reference to the network’s surface

Source

pub const fn points(&self) -> &Vec<Point<T>>

returns an immutable reference to the network’s critical points

Source

pub fn points_mut(&mut self) -> &mut Vec<Point<T>>

returns a mutable reference to the network’s critical points

Source

pub const fn input(&self) -> &Params<T>

returns an immutable reference to the network’s primary weights

Source

pub fn input_mut(&mut self) -> &mut Params<T>

returns a mutable reference to the network’s primary weights

Source

pub const fn input_bias(&self) -> &Array1<T>

returns an immutable reference to the model’s input layer bias

Source

pub fn input_bias_mut(&mut self) -> &mut Array1<T>

returns a mutable reference to the model’s input layer bias

Source

pub const fn input_weights(&self) -> &Array2<T>

returns an immutable reference to the model’s input layer weights

Source

pub fn input_weights_mut(&mut self) -> &mut Array2<T>

returns a mutable reference to the model’s input layer weights

Source

pub const fn hidden(&self) -> &Vec<Params<T>>

returns an immutable reference to the model’s hidden layers

Source

pub fn hidden_mut(&mut self) -> &mut Vec<Params<T>>

returns a mutable reference to the model’s hidden layers

Source

pub const fn output(&self) -> &Params<T>

returns an immutable reference to the network’s secondary weights

Source

pub fn output_mut(&mut self) -> &mut Params<T>

returns a mutable reference to the network’s secondary weights

Source

pub const fn output_bias(&self) -> &Array1<T>

returns an immutable reference to the model’s output layer bias

Source

pub fn output_bias_mut(&mut self) -> &mut Array1<T>

returns a mutable reference to the model’s output layer bias

Source

pub const fn output_weights(&self) -> &Array2<T>

returns an immutable reference to the model’s output layer weights

Source

pub fn output_weights_mut(&mut self) -> &mut Array2<T>

returns a mutable reference to the model’s output layer weights

Source

pub fn extend_surface<I>(&mut self, iter: I)
where I: IntoIterator<Item = Point<T>>,

Source

pub fn set_points<I>(&mut self, iter: I)
where I: IntoIterator<Item = Point<T>>,

set the critical points of the network

Source

pub fn with_attention(self) -> Self
where T: FromPrimitive,

enable the attention mechanism in the model

Source

pub fn with_points<I>(self, iter: I) -> Self
where I: IntoIterator<Item = Point<T>>,

consumes the current instance and returns another with the given points

Trait Implementations§

Source§

impl<T: Clone> Clone for SurfaceNetwork<T>

Source§

fn clone(&self) -> SurfaceNetwork<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for SurfaceNetwork<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A, X, Y> Forward<X> for SurfaceNetwork<A>
where A: Float + FromPrimitive + NumAssign + ScalarOperand, SurfaceModel<A>: Forward<X, Output = Y>,

Source§

type Output = Y

Source§

fn forward(&self, input: &X) -> Result<Self::Output>

a single forward step
Source§

fn forward_then<F>(&self, input: &Rhs, then: F) -> Result<Self::Output, Error>
where F: FnOnce(Self::Output) -> Self::Output,

this method enables the forward pass to be generically activated using some closure. This is useful for isolating the logic of the forward pass from that of the activation function and is often used by layers and models.
Source§

impl<T> PartialEq for SurfaceNetwork<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<A, X, Y, Z> Train<X, Y> for SurfaceNetwork<A>
where A: Float + FromPrimitive + NumAssign + ScalarOperand, SurfaceModel<A>: Train<X, Y, Output = Z>,

Source§

type Output = Z

Source§

fn train( &mut self, input: &X, expected: &Y, ) -> Result<Self::Output, NeuralError>

Source§

fn train_for( &mut self, input: &X, target: &Y, epochs: usize, ) -> Result<Self::Output, NeuralError>

Auto Trait Implementations§

§

impl<T> Freeze for SurfaceNetwork<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for SurfaceNetwork<T>
where T: RefUnwindSafe,

§

impl<T> Send for SurfaceNetwork<T>
where T: Send,

§

impl<T> Sync for SurfaceNetwork<T>
where T: Sync,

§

impl<T> Unpin for SurfaceNetwork<T>
where T: Unpin,

§

impl<T> UnwindSafe for SurfaceNetwork<T>

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> AsWeight<T> for T
where T: Clone + IntoWeight<T>,

Source§

fn as_weight(&self) -> Weight<T>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<K, S> Identity<K> for S
where S: Borrow<K>, K: Identifier,

Source§

type Item = S

Source§

fn get(&self) -> &<S as Identity<K>>::Item

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoWeight<T> for T

Source§

impl<A, B, C> PercentDifference<B> for A
where A: Clone, B: Sub<A, Output = C>, C: Div<A, Output = C>,

Source§

type Output = C

Source§

fn percent_diff(self, rhs: B) -> <A as PercentDifference<B>>::Output

Computes the percent difference between two values.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<M, U, V> Predict<U> for M
where M: Forward<U, Output = V>,

Source§

type Output = V

Source§

fn __private__(&self) -> Seal

Source§

fn predict(&self, input: &U) -> Result<<M as Predict<U>>::Output, NeuralError>

Source§

impl<M, U, A, D> PredictWithConfidence<U> for M
where A: Float + FromPrimitive + ScalarOperand, D: Dimension, M: Predict<U, Output = ArrayBase<OwnedRepr<A>, D>>,

Source§

impl<Q> RawState for Q
where Q: Send + Sync + Debug,

Source§

fn __private__(&self) -> Seal

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more