pub struct DartsCell {
pub n_nodes: usize,
pub n_input_nodes: usize,
pub edges: Vec<Vec<MixedOperation>>,
}Expand description
A DARTS cell: a DAG with n_input_nodes fixed inputs and n_nodes
intermediate nodes. Each node aggregates outputs from all prior nodes via
MixedOperation edges.
Fields§
§n_nodes: usizeNumber of intermediate (learnable) nodes.
n_input_nodes: usizeNumber of fixed input nodes (typically 2 in the standard DARTS setup).
edges: Vec<Vec<MixedOperation>>edges[i][j] is the MixedOperation from node j to intermediate node i.
Node indices: 0..n_input_nodes are inputs; n_input_nodes..n_input_nodes+n_nodes are
intermediate nodes.
Implementations§
Source§impl DartsCell
impl DartsCell
Sourcepub fn new(
n_input_nodes: usize,
n_intermediate_nodes: usize,
n_ops: usize,
) -> Self
pub fn new( n_input_nodes: usize, n_intermediate_nodes: usize, n_ops: usize, ) -> Self
Create a new DARTS cell.
§Arguments
n_input_nodes: Number of input nodes (preceding-cell outputs).n_intermediate_nodes: Number of intermediate nodes to build.n_ops: Number of candidate operations per edge.
Sourcepub fn forward(&mut self, inputs: &[Vec<f64>], temperature: f64) -> Vec<f64>
pub fn forward(&mut self, inputs: &[Vec<f64>], temperature: f64) -> Vec<f64>
Forward pass through the cell.
Each intermediate node output = Σ_{j < i} mixed_op_{ij}(node_j_output). Final cell output = concatenation of all intermediate node outputs.
§Arguments
inputs: Outputs of the n_input_nodes preceding this cell.temperature: Softmax temperature forwarded to eachMixedOperation.
Sourcepub fn arch_parameters(&self) -> Vec<f64>
pub fn arch_parameters(&self) -> Vec<f64>
Collect all architecture parameters from every edge in this cell, flattened.
Sourcepub fn update_arch_params(
&mut self,
grads: &[f64],
lr: f64,
) -> OptimizeResult<()>
pub fn update_arch_params( &mut self, grads: &[f64], lr: f64, ) -> OptimizeResult<()>
Apply gradient updates to architecture parameters using a gradient slice.
grads must have the same length as arch_parameters().
Sourcepub fn derive_discrete(&self) -> Vec<Vec<usize>>
pub fn derive_discrete(&self) -> Vec<Vec<usize>>
Derive the discrete architecture for this cell: argmax per edge.
Returns a Vec<Vec<usize>> with the same shape as edges, where each
entry is the index of the best operation.
Source§impl DartsCell
impl DartsCell
Sourcepub fn set_arch_params(&mut self, params: &[f64]) -> OptimizeResult<()>
pub fn set_arch_params(&mut self, params: &[f64]) -> OptimizeResult<()>
Replace all architecture parameters with values from the flat slice.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DartsCell
impl RefUnwindSafe for DartsCell
impl Send for DartsCell
impl Sync for DartsCell
impl Unpin for DartsCell
impl UnsafeUnpin for DartsCell
impl UnwindSafe for DartsCell
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
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>
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>
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.