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
impl MbConvBlock
Sourcepub fn new(config: MbConvConfig, rng: &mut VisionRng) -> VisionResult<Self>
pub fn new(config: MbConvConfig, rng: &mut VisionRng) -> VisionResult<Self>
Construct a new MBConv block with Xavier-uniform weight initialization.
§Errors
VisionError::InvalidImageSizeifin_channelsorout_channelsis 0.VisionError::InvalidEmbedDimifexpand_ratiois 0.VisionError::NonPositiveTemperatureifse_ratio ≤ 0.
Sourcepub fn forward(&self, x: &[f32], batch_size: usize) -> VisionResult<Vec<f32>>
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)
- Expand :
h = ReLU6(W_exp · x + b_exp)output:[exp_ch] - 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 usedw_w[c]as a per-channel scale (mean of k×k filter weights). - SE : global pool → FC1+ReLU → FC2+sigmoid → broadcast multiply.
- Project :
out = W_proj · h_se + b_proj(no activation). - Skip : if
has_skip,out += x.
§Errors
VisionError::DimensionMismatchifx.len() != batch_size * in_channels.
Auto Trait Implementations§
impl Freeze for MbConvBlock
impl RefUnwindSafe for MbConvBlock
impl Send for MbConvBlock
impl Sync for MbConvBlock
impl Unpin for MbConvBlock
impl UnsafeUnpin for MbConvBlock
impl UnwindSafe for MbConvBlock
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