native_neural_network 0.1.6

Lib no_std Rust for native neural network (.rnn)
Documentation
use crate::layers::LayerSpec;

pub fn layer_chain_is_compatible(layers: &[LayerSpec]) -> bool {
    if layers.is_empty() {
        return false;
    }
    for i in 1..layers.len() {
        if layers[i - 1].output_size() != layers[i].input_size() {
            return false;
        }
    }
    true
}

pub fn total_weight_count(layers: &[LayerSpec]) -> Option<usize> {
    let mut total = 0usize;
    for layer in layers {
        match layer {
            LayerSpec::Dense(d) => {
                total = total.checked_add(d.weight_len()?)?;
            }
        }
    }
    Some(total)
}

pub fn total_bias_count(layers: &[LayerSpec]) -> Option<usize> {
    let mut total = 0usize;
    for layer in layers {
        total = total.checked_add(layer.output_size())?;
    }
    Some(total)
}