3 个版本
0.1.2 | 2024 年 7 月 21 日 |
---|---|
0.1.1 | 2024 年 7 月 21 日 |
0.1.0 | 2024 年 7 月 21 日 |
#184 在 机器学习
每月 261 次下载
25KB
511 代码行
Neuroforge
Neuroforge 是一个 Rust 库,用于创建和训练具有集成神经符号处理层的神经网络。
1. 使用方法
以下是使用 neuroforge
库的基本示例
use neuroforge::{NeuroForge, neuro_symbolic::NeuroSymbolicLayer};
fn main() {
// Create a new neural network with 5 input neurons, 10 hidden neurons, and 3 output neurons
let mut network = NeuroForge::new(&[5, 10, 3]);
let mut symbolic_layer = NeuroSymbolicLayer::new();
// Add a neuro-symbolic rule
symbolic_layer.add_rule("high_activation", Box::new(|output: &[f64]| {
if output.iter().any(|&x| x > 0.8) { 1.0 } else { 0.0 }
}));
// Train the network
let inputs = vec![vec![0.1, 0.2, 0.3, 0.4, 0.5]];
let targets = vec![vec![0.9, 0.1, 0.5]];
network.train(&inputs, &targets, 1000);
// Make a prediction
let input = vec![0.2, 0.3, 0.4, 0.5, 0.6];
let mut output = network.forward(&input);
// Apply neuro-symbolic processing
output = symbolic_layer.process(output);
println!("Output: {:?}", output);
println!("Explanations: {:?}", symbolic_layer.explain());
}
2. 特点
- 神经网络创建:轻松创建具有指定架构的神经网络。
- 训练:使用输入-目标对训练网络。
- 前向传播:执行前向传播以获取网络输出。
- 神经符号处理:将符号规则集成到神经网络输出后处理中。
3. 安装
将 neuroforge
添加到您的 Cargo.toml
[dependencies]
neuroforge = "*"
或者命令
cargo add neuroforge
4. 许可证
该项目受 MIT 许可证许可。
依赖关系
~1.5MB
~32K SLoC