pub struct TransformerModel<T = f64> {
pub config: StandardModelConfig<T>,
pub features: ModelFeatures,
pub params: ModelParamsBase<OwnedRepr<T>>,
}Fields§
§config: StandardModelConfig<T>§features: ModelFeatures§params: ModelParamsBase<OwnedRepr<T>>Implementations§
Source§impl<T> TransformerModel<T>
impl<T> TransformerModel<T>
pub fn new( config: StandardModelConfig<T>, features: ModelFeatures, ) -> TransformerModel<T>
pub fn init(self) -> TransformerModel<T>
pub const fn config(&self) -> &StandardModelConfig<T>
pub fn config_mut(&mut self) -> &mut StandardModelConfig<T>
pub const fn features(&self) -> ModelFeatures
pub const fn params(&self) -> &ModelParamsBase<OwnedRepr<T>>
pub fn params_mut(&mut self) -> &mut ModelParamsBase<OwnedRepr<T>>
Trait Implementations§
Source§impl<A, U, V> Forward<U> for TransformerModel<A>where
V: ReLU<Output = V> + Sigmoid<Output = V> + for<'a> Add<&'a ArrayBase<OwnedRepr<A>, Dim<[usize; 1]>>, Output = V>,
A: FromPrimitive + ScalarOperand + Float,
ParamsBase<OwnedRepr<A>>: Forward<U, Output = V, Output = V> + Forward<V>,
&'a U: for<'a> Dot<ArrayBase<OwnedRepr<A>, Dim<[usize; 2]>>, Output = V> + for<'a> Add<&'a ArrayBase<OwnedRepr<A>, Dim<[usize; 1]>>>,
impl<A, U, V> Forward<U> for TransformerModel<A>where
V: ReLU<Output = V> + Sigmoid<Output = V> + for<'a> Add<&'a ArrayBase<OwnedRepr<A>, Dim<[usize; 1]>>, Output = V>,
A: FromPrimitive + ScalarOperand + Float,
ParamsBase<OwnedRepr<A>>: Forward<U, Output = V, Output = V> + Forward<V>,
&'a U: for<'a> Dot<ArrayBase<OwnedRepr<A>, Dim<[usize; 2]>>, Output = V> + for<'a> Add<&'a ArrayBase<OwnedRepr<A>, Dim<[usize; 1]>>>,
type Output = V
Source§fn forward(
&self,
input: &U,
) -> Result<<TransformerModel<A> as Forward<U>>::Output, Error>
fn forward( &self, input: &U, ) -> Result<<TransformerModel<A> as Forward<U>>::Output, Error>
a single forward step
Source§fn forward_then<F>(&self, input: &Rhs, then: F) -> Result<Self::Output, Error>
fn forward_then<F>(&self, input: &Rhs, then: F) -> Result<Self::Output, Error>
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> Model<T> for TransformerModel<T>
impl<T> Model<T> for TransformerModel<T>
Source§type Config = StandardModelConfig<T>
type Config = StandardModelConfig<T>
The configuration type for the model
Source§type Layout = ModelFeatures
type Layout = ModelFeatures
the type of layout used by the model
Source§fn config(&self) -> &StandardModelConfig<T>
fn config(&self) -> &StandardModelConfig<T>
returns an immutable reference to the models configuration; this is typically used to
access the models hyperparameters (i.e. learning rate, momentum, etc.) and other
related control parameters.
Source§fn config_mut(&mut self) -> &mut StandardModelConfig<T>
fn config_mut(&mut self) -> &mut StandardModelConfig<T>
returns a mutable reference to the models configuration; useful for setting hyperparams
Source§fn layout(&self) -> ModelFeatures
fn layout(&self) -> ModelFeatures
returns a copy of the model’s current layout (features); a type providing the model
with a particular number of features for the various layers of a deep neural network. Read more
Source§fn params(&self) -> &ModelParamsBase<OwnedRepr<T>>
fn params(&self) -> &ModelParamsBase<OwnedRepr<T>>
returns an immutable reference to the model parameters
Source§fn params_mut(&mut self) -> &mut ModelParamsBase<OwnedRepr<T>>
fn params_mut(&mut self) -> &mut ModelParamsBase<OwnedRepr<T>>
returns a mutable reference to the model’s parameters
Source§fn predict<U, V>(&self, inputs: &U) -> Result<V, NeuralError>where
Self: Predict<U, Output = V>,
fn predict<U, V>(&self, inputs: &U) -> Result<V, NeuralError>where
Self: Predict<U, Output = V>,
propagates the input through the model; each layer is applied in sequence meaning that
the output of each previous layer is the input to the next layer. This pattern
repeats until the output layer returns the final result. Read more
Source§fn train<U, V, W>(
&mut self,
dataset: &DatasetBase<U, V>,
) -> Result<W, NeuralError>where
Self: Train<U, V, Output = W>,
fn train<U, V, W>(
&mut self,
dataset: &DatasetBase<U, V>,
) -> Result<W, NeuralError>where
Self: Train<U, V, Output = W>,
a convience method that trains the model using the provided dataset; this method
requires that the model implements the
Train trait and that the datasetSource§impl<A, S, T> Train<ArrayBase<S, Dim<[usize; 1]>>, ArrayBase<T, Dim<[usize; 1]>>> for TransformerModel<A>where
A: Float + FromPrimitive + NumAssign + ScalarOperand + Debug,
S: Data<Elem = A>,
T: Data<Elem = A>,
impl<A, S, T> Train<ArrayBase<S, Dim<[usize; 1]>>, ArrayBase<T, Dim<[usize; 1]>>> for TransformerModel<A>where
A: Float + FromPrimitive + NumAssign + ScalarOperand + Debug,
S: Data<Elem = A>,
T: Data<Elem = A>,
type Output = A
fn train( &mut self, input: &ArrayBase<S, Dim<[usize; 1]>>, target: &ArrayBase<T, Dim<[usize; 1]>>, ) -> Result<<TransformerModel<A> as Train<ArrayBase<S, Dim<[usize; 1]>>, ArrayBase<T, Dim<[usize; 1]>>>>::Output, NeuralError>
fn train_for( &mut self, input: &X, target: &Y, epochs: usize, ) -> Result<Self::Output, NeuralError>
Source§impl<A, S, T> Train<ArrayBase<S, Dim<[usize; 2]>>, ArrayBase<T, Dim<[usize; 2]>>> for TransformerModel<A>where
A: Float + FromPrimitive + NumAssign + ScalarOperand + Debug,
S: Data<Elem = A>,
T: Data<Elem = A>,
impl<A, S, T> Train<ArrayBase<S, Dim<[usize; 2]>>, ArrayBase<T, Dim<[usize; 2]>>> for TransformerModel<A>where
A: Float + FromPrimitive + NumAssign + ScalarOperand + Debug,
S: Data<Elem = A>,
T: Data<Elem = A>,
type Output = A
fn train( &mut self, input: &ArrayBase<S, Dim<[usize; 2]>>, target: &ArrayBase<T, Dim<[usize; 2]>>, ) -> Result<<TransformerModel<A> as Train<ArrayBase<S, Dim<[usize; 2]>>, ArrayBase<T, Dim<[usize; 2]>>>>::Output, NeuralError>
fn train_for( &mut self, input: &X, target: &Y, epochs: usize, ) -> Result<Self::Output, NeuralError>
Auto Trait Implementations§
impl<T> Freeze for TransformerModel<T>
impl<T> RefUnwindSafe for TransformerModel<T>where
T: RefUnwindSafe,
impl<T> Send for TransformerModel<T>where
T: Send,
impl<T> Sync for TransformerModel<T>where
T: Sync,
impl<T> Unpin for TransformerModel<T>where
T: Unpin,
impl<T> UnwindSafe for TransformerModel<T>where
T: UnwindSafe + RefUnwindSafe,
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