5 个不稳定版本
使用旧的 Rust 2015
0.3.0 | 2024 年 3 月 17 日 |
---|---|
0.2.5 | 2024 年 3 月 14 日 |
0.1.3 | 2024 年 3 月 14 日 |
#312 in 机器学习
174 个月下载量
9KB
112 行
Hextral
Hextral 是一个 Rust 库,用于实现具有 L2 和 L1 正则化等正则化技术的神经网络。
特性
- 实现具有可定制激活函数(Sigmoid、ReLU、Tanh)的神经网络。
- 支持 L2 和 L1 正则化以控制过拟合。
- 提供训练神经网络、进行预测和评估性能的方法。
- 使用 nalgebra crate 构建,以实现高效的线性代数运算。
使用方法
将此 crate 添加到您的 Cargo.toml
[dependencies]
hextral = "0.1.0"
然后,您可以在 Rust 项目中使用 Hextral 如下
use hextral::{Hextral, ActivationFunction, Regularization};
use nalgebra::{DVector, DMatrix};
fn main() {
// Create a new Hextral neural network
let mut hextral = Hextral::new(0.1, 0.2);
// Generate training data (inputs and targets)
let inputs = vec![
DVector::from_iterator(10, (0..10).map(|_| rand::random::<f64>())),
// Add more input vectors as needed
];
let targets = vec![
DVector::from_iterator(10, (0..10).map(|_| rand::random::<f64>())),
// Add corresponding target vectors as needed
];
// Train the neural network
hextral.train(&inputs, &targets, 0.01, Regularization::L2(0.001), 100);
// Make predictions
let input = DVector::from_iterator(10, (0..10).map(|_| rand::random::<f64>()));
let prediction = hextral.predict(&input);
println!("Prediction: {:?}", prediction);
// Evaluate the model
let evaluation_loss = hextral.evaluate(&inputs, &targets);
println!("Evaluation Loss: {}", evaluation_loss);
}
有关可用方法和选项的更多详细信息,请参阅 文档。
许可协议
本项目采用 MIT 许可协议 - 有关详细信息,请参阅 LICENSE 文件。
依赖项
~3MB
~61K SLoC