Skip to main content

MbConvBlock

Struct MbConvBlock 

Source
pub struct MbConvBlock { /* private fields */ }
Expand description

EfficientNet MBConv inverted residual block.

Weight layout (row-major):

  • expand_w: [exp_ch × in_ch] (1×1 expand conv, bias: expand_b [exp_ch])
  • dw_w : [exp_ch × k × k] (depthwise weights, bias: dw_b [exp_ch])
  • se_fc1_w: [se_ch × exp_ch] (SE squeeze, bias: se_fc1_b [se_ch])
  • se_fc2_w: [exp_ch × se_ch] (SE excite, bias: se_fc2_b [exp_ch])
  • proj_w : [out_ch × exp_ch] (1×1 project conv, bias: proj_b [out_ch])

Implementations§

Source§

impl MbConvBlock

Source

pub fn new(config: MbConvConfig, rng: &mut VisionRng) -> VisionResult<Self>

Construct a new MBConv block with Xavier-uniform weight initialization.

§Errors
Source

pub fn has_skip(&self) -> bool

Whether this block uses a skip (residual) connection.

Source

pub fn forward(&self, x: &[f32], batch_size: usize) -> VisionResult<Vec<f32>>

Forward pass.

§Input / output layout

x: [batch_size × in_channels] row-major. Returns: [batch_size × out_channels] row-major.

§Pipeline (per sample)
  1. Expand : h = ReLU6(W_exp · x + b_exp) output: [exp_ch]
  2. Depthwise : channel-wise multiplication by dw_w[c, :] mean (1D proxy), then bias + ReLU6. Full 2-D depthwise conv would require H×W spatial input; here we use dw_w[c] as a per-channel scale (mean of k×k filter weights).
  3. SE : global pool → FC1+ReLU → FC2+sigmoid → broadcast multiply.
  4. Project : out = W_proj · h_se + b_proj (no activation).
  5. Skip : if has_skip, out += x.
§Errors

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> 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.