1 个不稳定版本

0.0.1 2023 年 3 月 21 日

#7 in #neuron

MIT/Apache

32KB
691

Cerebral

警告:建设中

一个用于研究目的的自组织神经网络组合算法的包。


lib.rs:

命名约定

  • 特质:以大写字母开头,是形容词
  • 结构体:以大写字母开头,是名词
use som_rs::default::*;
use som_rs::{NeuralLayer, Neurons, SelfOrganizing};

fn main() {
    println!("Hello, SOM!");

    let seed = 42;

    let mut rng = Isaac64Rng::seed_from_u64(seed);

    let mut som = NeuralLayer {
        neurons: Neurons {
            // lateral: Array2::<f64>::zeros((0,0)),
            patterns: Array::random_using((100, 3), Uniform::new(0., 10.), &mut rng),
            ..Default::default()
        },
        adaptivity: KohonenAdaptivity {},
        topology: CartesianTopology::new((10, 10)),
        responsiveness: CartesianResponsiveness {},
        training: BatchTraining {
            radii: (2.0, 0.2),
            rates: (0.7, 0.1),
            epochs: 1,
        },
    };

    println!("{}", som.neurons.lateral);

    som.init_lateral();
    let training = Array::random_using((5000, 2), Uniform::new(0., 9.), &mut rng);
    som.train(&training);
    som.adapt(&training.row(0), 0.7, 0.7);
}

依赖项

~2.5MB
~52K SLoC