pub enum Layer<B: Backend> {
Show 24 variants
Attention(Attention<B>),
Bias(Bias<B>),
BatchNorm(BatchNorm<B>),
Cache(Cache<B>),
Cat(Ignored<CatLayer>),
Conv2d(Conv2d<B>),
CrossEntropy(CrossEntropyLoss<B>),
Dropout(Dropout),
Embedding(Embedding<B>),
Flatten(Ignored<FlattenLayer<Range<isize>>>),
KQV(KQV<B>),
LayerNorm(LayerNorm<B>),
Linear(Linear<B>),
MaxPool2d(MaxPool2d),
Mse(MseLoss),
Relu(Relu),
Reshape(Ignored<ReshapeLayer<Reshape>>),
Rotary(RotaryEncoding<B>),
ScaleShift(ScaleShift<B>),
Squeeze(Ignored<SqueezeLayer>),
Stack(Ignored<StackLayer>),
Sum(Ignored<SumLayer>),
Tanh(Tanh),
Unsqueeze(Ignored<UnsqueezeLayer>),
}Expand description
enumerates some burn layers
Variants§
Attention(Attention<B>)
Bias(Bias<B>)
BatchNorm(BatchNorm<B>)
Cache(Cache<B>)
Cat(Ignored<CatLayer>)
Conv2d(Conv2d<B>)
CrossEntropy(CrossEntropyLoss<B>)
Dropout(Dropout)
Embedding(Embedding<B>)
Flatten(Ignored<FlattenLayer<Range<isize>>>)
KQV(KQV<B>)
LayerNorm(LayerNorm<B>)
Linear(Linear<B>)
MaxPool2d(MaxPool2d)
Mse(MseLoss)
Relu(Relu)
Reshape(Ignored<ReshapeLayer<Reshape>>)
Rotary(RotaryEncoding<B>)
ScaleShift(ScaleShift<B>)
Squeeze(Ignored<SqueezeLayer>)
Stack(Ignored<StackLayer>)
Sum(Ignored<SumLayer>)
Tanh(Tanh)
Unsqueeze(Ignored<UnsqueezeLayer>)
Implementations§
Source§impl<B: Backend> Layer<B>
impl<B: Backend> Layer<B>
Sourcepub fn attention(heads: usize, mask: AttentionMask) -> Self
pub fn attention(heads: usize, mask: AttentionMask) -> Self
creates an attention config
Sourcepub fn batch_norm(countfeatures: usize, epsilon: f32, momentum: f32) -> Self
pub fn batch_norm(countfeatures: usize, epsilon: f32, momentum: f32) -> Self
creates a batch norm layer
Sourcepub fn clear_cache(&mut self) -> bool
pub fn clear_cache(&mut self) -> bool
clears the cache if the layer has one
Sourcepub fn flatten<R: RangeBounds<isize>>(dims: R) -> Self
pub fn flatten<R: RangeBounds<isize>>(dims: R) -> Self
creates a flatten layer
Sourcepub fn layer_norm(dim: usize) -> Self
pub fn layer_norm(dim: usize) -> Self
creates a layer norm layer
Sourcepub fn linear(bias: bool, input: usize, output: usize, wscale: f32) -> Self
pub fn linear(bias: bool, input: usize, output: usize, wscale: f32) -> Self
creates a linear layer
Sourcepub fn max_pool_2d(kernel: [usize; 2], strides: [usize; 2]) -> Self
pub fn max_pool_2d(kernel: [usize; 2], strides: [usize; 2]) -> Self
creates a max pool 2d layer
Sourcepub fn scale_shift() -> Self
pub fn scale_shift() -> Self
creates a scale shift layer
Trait Implementations§
Source§impl<B> AutodiffModule<B> for Layer<B>
impl<B> AutodiffModule<B> for Layer<B>
Source§type InnerModule = Layer<<B as AutodiffBackend>::InnerBackend>
type InnerModule = Layer<<B as AutodiffBackend>::InnerBackend>
Inner module without auto-differentiation.
Source§fn valid(&self) -> Self::InnerModule
fn valid(&self) -> Self::InnerModule
Get the same module, but on the inner backend without auto-differentiation.
Source§impl<B: Backend> Decompose for Layer<B>
impl<B: Backend> Decompose for Layer<B>
Source§type Decomposition = Layer<B>
type Decomposition = Layer<B>
the decomposed type
Source§fn compose(decomposition: Self::Decomposition) -> Self
fn compose(decomposition: Self::Decomposition) -> Self
recreates from the decomposition
Source§fn decompose(self) -> Self::Decomposition
fn decompose(self) -> Self::Decomposition
owned decomposition
Source§fn decompose_cloned(&self) -> Self::Decomposition
fn decompose_cloned(&self) -> Self::Decomposition
decomposition that copies data
Source§impl<'de, B: Backend> Deserialize<'de> for Layer<B>
impl<'de, B: Backend> Deserialize<'de> for Layer<B>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<B: Backend> From<CrossEntropyLoss<B>> for Layer<B>
impl<B: Backend> From<CrossEntropyLoss<B>> for Layer<B>
Source§fn from(value: CrossEntropyLoss<B>) -> Self
fn from(value: CrossEntropyLoss<B>) -> Self
Converts to this type from the input type.
Source§impl<B: Backend> From<ReshapeLayer<Reshape>> for Layer<B>
impl<B: Backend> From<ReshapeLayer<Reshape>> for Layer<B>
Source§fn from(value: ReshapeLayer<Reshape>) -> Self
fn from(value: ReshapeLayer<Reshape>) -> Self
Converts to this type from the input type.
Source§impl<B: Backend> From<RotaryEncoding<B>> for Layer<B>
impl<B: Backend> From<RotaryEncoding<B>> for Layer<B>
Source§fn from(value: RotaryEncoding<B>) -> Self
fn from(value: RotaryEncoding<B>) -> Self
Converts to this type from the input type.
Source§impl<B: Backend> From<SqueezeLayer> for Layer<B>
impl<B: Backend> From<SqueezeLayer> for Layer<B>
Source§fn from(value: SqueezeLayer) -> Self
fn from(value: SqueezeLayer) -> Self
Converts to this type from the input type.
Source§impl<B: Backend> From<StackLayer> for Layer<B>
impl<B: Backend> From<StackLayer> for Layer<B>
Source§fn from(value: StackLayer) -> Self
fn from(value: StackLayer) -> Self
Converts to this type from the input type.
Source§impl<B: Backend> From<UnsqueezeLayer> for Layer<B>
impl<B: Backend> From<UnsqueezeLayer> for Layer<B>
Source§fn from(value: UnsqueezeLayer) -> Self
fn from(value: UnsqueezeLayer) -> Self
Converts to this type from the input type.
Source§impl<B: Backend, M: AI<M::Output, M::Output> + Op> IntoSequence<M> for Layer<B>
impl<B: Backend, M: AI<M::Output, M::Output> + Op> IntoSequence<M> for Layer<B>
Source§fn into_sequence(self) -> Sequential<Vec<M>>
fn into_sequence(self) -> Sequential<Vec<M>>
converts into a sequential module list
Source§impl<B: Backend> Module<B> for Layer<B>
impl<B: Backend> Module<B> for Layer<B>
Source§fn load_record(self, record: Self::Record) -> Self
fn load_record(self, record: Self::Record) -> Self
Load the module state from a record.
Source§fn into_record(self) -> Self::Record
fn into_record(self) -> Self::Record
Convert the module into a record containing the state.
Source§fn num_params(&self) -> usize
fn num_params(&self) -> usize
Get the number of parameters the module has, including all of its sub-modules.
Source§fn visit<Visitor: ModuleVisitor<B>>(&self, visitor: &mut Visitor)
fn visit<Visitor: ModuleVisitor<B>>(&self, visitor: &mut Visitor)
Visit each tensor parameter in the module with a visitor.
Source§fn map<Mapper: ModuleMapper<B>>(self, mapper: &mut Mapper) -> Self
fn map<Mapper: ModuleMapper<B>>(self, mapper: &mut Mapper) -> Self
Map each tensor parameter in the module with a mapper.
Source§fn collect_devices(&self, devices: Devices<B>) -> Devices<B>
fn collect_devices(&self, devices: Devices<B>) -> Devices<B>
Return all the devices found in the underneath module tree added to the given vector
without duplicates.
Source§fn to_device(self, device: &B::Device) -> Self
fn to_device(self, device: &B::Device) -> Self
Move the module and all of its sub-modules to the given device. Read more
Source§fn fork(self, device: &B::Device) -> Self
fn fork(self, device: &B::Device) -> Self
Fork the module and all of its sub-modules to the given device. Read more
Source§fn devices(&self) -> Vec<<B as Backend>::Device>
fn devices(&self) -> Vec<<B as Backend>::Device>
Return all the devices found in the underneath module tree without duplicates.
Source§fn save_file<FR, PB>(
self,
file_path: PB,
recorder: &FR,
) -> Result<(), RecorderError>
fn save_file<FR, PB>( self, file_path: PB, recorder: &FR, ) -> Result<(), RecorderError>
Save the module to a file using the provided file recorder. Read more
Source§fn load_file<FR, PB>(
self,
file_path: PB,
recorder: &FR,
device: &<B as Backend>::Device,
) -> Result<Self, RecorderError>
fn load_file<FR, PB>( self, file_path: PB, recorder: &FR, device: &<B as Backend>::Device, ) -> Result<Self, RecorderError>
Load the module from a file using the provided file recorder. Read more
Source§fn quantize_weights(self, quantizer: &mut Quantizer) -> Self
fn quantize_weights(self, quantizer: &mut Quantizer) -> Self
Quantize the weights of the module.
Source§impl<B: Backend> ModuleDisplay for Layer<B>
impl<B: Backend> ModuleDisplay for Layer<B>
Source§fn format(&self, passed_settings: DisplaySettings) -> String
fn format(&self, passed_settings: DisplaySettings) -> String
Formats the module with provided display settings. Read more
Source§fn custom_settings(&self) -> Option<DisplaySettings>
fn custom_settings(&self) -> Option<DisplaySettings>
Custom display settings for the module. Read more
Source§impl<B: Backend> ModuleDisplayDefault for Layer<B>
impl<B: Backend> ModuleDisplayDefault for Layer<B>
Source§impl<B: Backend> Op for Layer<B>
impl<B: Backend> Op for Layer<B>
Source§type Output = Value<B>
type Output = Value<B>
suggested output type to help with composition coherence. Ideally, Self should implement AI<X,Self::Output> for some X
Source§fn chain<B>(self, b: B) -> Sequential<(Self, B)>
fn chain<B>(self, b: B) -> Sequential<(Self, B)>
sequences with another ai operation
Source§fn cross_entropy(self, temperature: f32) -> CrossEntropy<Self>
fn cross_entropy(self, temperature: f32) -> CrossEntropy<Self>
wraps with a cross entropy operation. If temperature is a number it will be used to apply softmax to the logits before computing entropy with the target. if the input will already be a probability distribution instead of logits, put NaN temperature
Source§fn forward_fixed<Z>(&self, input: Z) -> Z
fn forward_fixed<Z>(&self, input: Z) -> Z
applies to the input
Source§fn forward_fixed_mut<Z>(&mut self, input: Z) -> Z
fn forward_fixed_mut<Z>(&mut self, input: Z) -> Z
applies to the input
Source§fn forward_typed<W, Z>(&self, input: W) -> Z
fn forward_typed<W, Z>(&self, input: W) -> Z
applies to the input
Source§fn forward_typed_mut<W, Z>(&mut self, input: W) -> Z
fn forward_typed_mut<W, Z>(&mut self, input: W) -> Z
applies to the input, possibly updating internal caches
Source§fn infer_autoregressive<X, Y>(self, input: X) -> Autoregression<Self, Y> ⓘ
fn infer_autoregressive<X, Y>(self, input: X) -> Autoregression<Self, Y> ⓘ
creates an autoregressive inference
Source§fn map<B>(self, b: B) -> Map<Sequential<(Self, B)>>
fn map<B>(self, b: B) -> Map<Sequential<(Self, B)>>
applies the operation to every output
Source§fn soft_choose(self, temperature: f32) -> Choose<Self>
fn soft_choose(self, temperature: f32) -> Choose<Self>
wraps with a choose operation
Source§fn squared_error(self) -> SquaredError<Self>
fn squared_error(self) -> SquaredError<Self>
wraps with a mse operation
Source§fn wrap_inner(self) -> Inner<Self>where
Self: Sized,
fn wrap_inner(self) -> Inner<Self>where
Self: Sized,
wraps the inner value so it can be unwrapped with unwrap inner
Auto Trait Implementations§
impl<B> !Freeze for Layer<B>
impl<B> !RefUnwindSafe for Layer<B>
impl<B> Send for Layer<B>
impl<B> !Sync for Layer<B>
impl<B> Unpin for Layer<B>where
B: Unpin,
<B as Backend>::BoolTensorPrimitive: Unpin,
<B as Backend>::IntTensorPrimitive: Unpin,
<B as Backend>::FloatTensorPrimitive: Unpin,
<B as Backend>::QuantizedTensorPrimitive: Unpin,
<B as Backend>::Device: Unpin,
impl<B> !UnwindSafe for Layer<B>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Shortcuts for T
impl<T> Shortcuts for T
Source§fn classification(self) -> Classification<Self>
fn classification(self) -> Classification<Self>
wraps in a classification wrapper
Source§fn regression(self) -> Regression<Self>
fn regression(self) -> Regression<Self>
wraps in a regression wrapper
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more