Skip to main content

NeuralNetwork

Struct NeuralNetwork 

Source
pub struct NeuralNetwork<L, C, B: Backend = DefaultBackend>
where L: Layer<B>,
{ pub layers: L, pub cost: C, /* private fields */ }

Fields§

§layers: L§cost: C

Implementations§

Source§

impl<L, C, B> NeuralNetwork<L, C, B>
where B: Backend, L: Layer<B> + Serialize + for<'de> Deserialize<'de>, C: Cost<B>,

Source

pub fn new(layers: L, cost: C) -> Self

Source

pub fn save<P: AsRef<Path>>(&self, path: P) -> Result<()>

Source

pub fn load<P: AsRef<Path>>(path: P, cost: C) -> Result<Self>

Source

pub fn forward(&mut self, input: &B::Tensor<L::Input>) -> B::Tensor<L::Output>

Source

pub fn backward( &mut self, grad_output: &B::Tensor<L::Output>, ) -> B::Tensor<L::Input>

Source

pub fn train<O, I, T>( &mut self, inputs: I, targets: T, optimizer: O, epochs: usize, batch_size: usize, ) -> Vec<f32>
where O: Optimizer<B>, I: Into<B::Tensor<L::Input>>, T: Into<B::Tensor<L::Output>>, L::Input: RemoveAxis, L::Output: RemoveAxis,

Trait Implementations§

Source§

impl<L, C, B> Forward<B> for NeuralNetwork<L, C, B>
where B: Backend, L: Layer<B> + Serialize + for<'de> Deserialize<'de>, C: Cost<B>,

Source§

type Input = <L as Layer<B>>::Input

Source§

type Output = <L as Layer<B>>::Output

Source§

fn run(&mut self, x: &B::Tensor<L::Input>) -> B::Tensor<L::Output>

Auto Trait Implementations§

§

impl<L, C, B> Freeze for NeuralNetwork<L, C, B>
where L: Freeze, C: Freeze,

§

impl<L, C, B> RefUnwindSafe for NeuralNetwork<L, C, B>

§

impl<L, C, B> Send for NeuralNetwork<L, C, B>
where L: Send, C: Send, B: Send,

§

impl<L, C, B> Sync for NeuralNetwork<L, C, B>
where L: Sync, C: Sync, B: Sync,

§

impl<L, C, B> Unpin for NeuralNetwork<L, C, B>
where L: Unpin, C: Unpin, B: Unpin,

§

impl<L, C, B> UnsafeUnpin for NeuralNetwork<L, C, B>
where L: UnsafeUnpin, C: UnsafeUnpin,

§

impl<L, C, B> UnwindSafe for NeuralNetwork<L, C, B>
where L: UnwindSafe, C: UnwindSafe, B: UnwindSafe,

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