Skip to main content

Yolo26Loss

Struct Yolo26Loss 

Source
pub struct Yolo26Loss {
    pub grid: AnchorGrid,
    pub assigner: TaskAlignedAssigner,
    pub assigner_o2o: TaskAlignedAssigner,
    pub nc: usize,
    pub cap: Capability,
    /* private fields */
}
Expand description

CUDA training loss for YOLO26: computes d_boxes and d_scores.

Fields§

§grid: AnchorGrid

Anchor grid (points + strides) for the model’s input resolution.

§assigner: TaskAlignedAssigner

One2many assigner (top_k=10) — used during compute_grads and the o2m head of compute_grads_dual.

§assigner_o2o: TaskAlignedAssigner

One2one assigner (top_k=1) — used for the o2o head of compute_grads_dual.

§nc: usize

Number of detection classes.

§cap: Capability

Target GPU compute capability for compiled kernels.

Implementations§

Source§

impl Yolo26Loss

Source

pub fn new(img_h: usize, img_w: usize, nc: usize, cap: Capability) -> Self

Builds the loss state for a model trained at img_h × img_w with nc classes.

Source

pub fn compute_grads( &self, device: &CudaDevice<'_>, boxes: &[f32], scores: &[f32], gt_boxes_b: &[Vec<[f32; 4]>], gt_cls_b: &[Vec<usize>], ) -> Result<(Vec<f32>, Vec<f32>)>

Compute loss gradients for one batch (one2many head only).

boxes – raw LTRB predictions [B, 4*A] (host f32, channels-first) scores – class logits [B, nc*A] (host f32, channels-first)

Returns (d_boxes [B,4*A], d_scores [B,nc*A]) as host f32.

Source

pub fn compute_grads_dual( &self, device: &CudaDevice<'_>, boxes_o2m: &[f32], scores_o2m: &[f32], boxes_o2o: &[f32], scores_o2o: &[f32], gt_boxes_b: &[Vec<[f32; 4]>], gt_cls_b: &[Vec<usize>], w_o2m: f32, w_o2o: f32, ) -> Result<(Vec<f32>, Vec<f32>, Vec<f32>, Vec<f32>)>

Compute dual-head loss gradients for consistent assignment training.

Runs TAL assignment independently for both heads using their respective assigners (top_k=10 for o2m, top_k=1 for o2o), then scales the resulting gradients by w_o2m and w_o2o respectively.

§Loss weight schedule (ultralytics-style)
  • w_o2m = 1.0 (constant throughout training)
  • w_o2o = step / total_steps (ramps 0→1 linearly; caller controls the schedule)

Returns (d_boxes_o2m, d_scores_o2m, d_boxes_o2o, d_scores_o2o).

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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> Same for T

Source§

type Output = T

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more