Skip to main content

SensorEncoderConfig

Struct SensorEncoderConfig 

Source
pub struct SensorEncoderConfig {
    pub time_steps: usize,
    pub num_channels: usize,
    pub patch_h: usize,
    pub patch_w: usize,
    pub d_model: usize,
    pub depth: usize,
    pub num_heads: usize,
    pub mlp_dim: usize,
    pub dropout: f64,
    pub pool_type: PoolType,
    pub head_zeroinit: bool,
    pub attn_chunk_size: usize,
}
Expand description

Configuration for the Vision Transformer sensor encoder.

The encoder treats wearable sensor data as a 2-D grid (TIME_STEPS × NUM_CHANNELS) and divides it into rectangular patches of shape (patch_h × patch_w).

Fields§

§time_steps: usize

Number of time-steps in the input signal (default: 1440 = 24 h × 60 min).

§num_channels: usize

Number of sensor channels (features) per time-step (default: 34).

§patch_h: usize

Patch height (time axis), default: 10 minutes.

§patch_w: usize

Patch width (channel axis), default: 2 channels.

§d_model: usize

Transformer hidden dimension (ViT-B = 768).

§depth: usize

Number of transformer layers (ViT-B = 12).

§num_heads: usize

Number of attention heads per layer (ViT-B = 12).

§mlp_dim: usize

Feed-forward MLP hidden dimension (ViT-B = 3072).

§dropout: f64

Dropout probability applied inside each transformer block.

§pool_type: PoolType

Type of sequence pooling used after the transformer. "map" (Multihead Attention Pooling) is the default and matches the reference implementation. "gap" (global average pooling) is a cheaper alternative.

§head_zeroinit: bool

Whether to zero-initialise the output projection in the MAP head.

§attn_chunk_size: usize

Chunked-attention window size (number of query rows per chunk).

Limits forward-pass peak attention memory from O(B·H·N²) to O(B·H·chunk·N) and keeps individual WGPU GPU dispatches small enough to avoid OS watchdog (TDR) timeouts.

⚠ Training caveat — chunking does NOT save backward memory. Burn’s autodiff tape records every intermediate tensor produced inside the chunk loop (q_chunk, scores, attn, chunk_out). All chunks for all layers are kept alive simultaneously until loss.backward() completes. True backward memory savings require gradient checkpointing, which is not yet implemented.

Rule of thumb for GPU VRAM (fp32, ViT-B, N = 2448, H = 12):

chunkfwd attn @ B=4fwd attn @ B=8
2448 (off)4.3 GB8.6 GB
256450 MB900 MB
128225 MB450 MB
64112 MB225 MB

Set to 0 to disable chunking (full N×N matrix — not recommended on GPU due to TDR risk and peak memory).

Default: 64.

Implementations§

Source§

impl SensorEncoderConfig

Source

pub fn num_patches(&self) -> usize

Total number of patches = (time_steps / patch_h) × (num_channels / patch_w).

Channel dimension is padded up to the next multiple of patch_w if num_channels is not evenly divisible.

Trait Implementations§

Source§

impl Clone for SensorEncoderConfig

Source§

fn clone(&self) -> SensorEncoderConfig

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 Debug for SensorEncoderConfig

Source§

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

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

impl Default for SensorEncoderConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SensorEncoderConfig

Source§

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 Serialize for SensorEncoderConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> 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<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> 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<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,