ZeroNeural.Core
1.2.0
dotnet add package ZeroNeural.Core --version 1.2.0
NuGet\Install-Package ZeroNeural.Core -Version 1.2.0
<PackageReference Include="ZeroNeural.Core" Version="1.2.0" />
<PackageVersion Include="ZeroNeural.Core" Version="1.2.0" />
<PackageReference Include="ZeroNeural.Core" />
paket add ZeroNeural.Core --version 1.2.0
#r "nuget: ZeroNeural.Core, 1.2.0"
#:package ZeroNeural.Core@1.2.0
#addin nuget:?package=ZeroNeural.Core&version=1.2.0
#tool nuget:?package=ZeroNeural.Core&version=1.2.0
ZeroNeural
ZeroNeural is a pure C# deep learning framework and automatic differentiation (Autograd) library for .NET with zero external dependencies. Providing a clean, PyTorch-like programming interface, it enables dynamic computational graph construction, reverse-mode automatic differentiation, neural network layer composition, and gradient optimization directly inside standard .NET applications without Python or native Torch binaries.
๐ Key Capabilities
- Reverse-Mode Autograd Engine: Dynamic tape-based computational DAG recording operations and backpropagating analytical vector-Jacobian products (
Backward()). - PyTorch-Style Neural Layers (
ZeroNeural.Core.nn):Linear(Dense fully-connected layer with Xavier/Kaiming initialization)Sequential(Composed container for multi-stage pipelines)Conv2D(Spatial convolution with backpropagation)Dropout(Inverted dropout for regularized training)BatchNorm(Batch normalization with running mean/variance)Activations: ReLU, Sigmoid, Tanh, Softmax, GELU
- Standard Loss Functions:
MseLoss(Mean Squared Error for regression)CrossEntropyLoss(Multi-class classification with numerical log-sum-exp stability)BceWithLogitsLoss(Binary classification with integrated sigmoid)
- First-Class Optimizers (
ZeroNeural.Core.Optim):AdamandAdamW(Adaptive Moment Estimation with decoupled weight decay)SGD(Stochastic Gradient Descent with Nesterov momentum)RMSProp
- Zero External Dependencies: Standard .NET runtime only.
๐ฆ Installation
Install via the .NET CLI:
dotnet add package ZeroNeural.Core
๐ Quick Start
1. Reverse-Mode Autograd Gradient Computation
using ZeroNeural.Core.Autograd;
using ZeroTensor.Core;
// Create leaf variable with gradient tracking
var x = new Variable(Tensor.Create(new[] { 1 }, new float[] { 3.0f }), requiresGrad: true);
// Compute y = x^2 + 2x + 1
var y = x * x + x * 2.0f + 1.0f;
// Backpropagate gradients: dy/dx = 2x + 2 = 8
y.Backward();
Console.WriteLine($"dy/dx at x=3: {x.Grad[0]} (Expected: 8.0)");
2. Training a Multi-Layer Perceptron (MLP)
using ZeroNeural.Core.nn;
using ZeroNeural.Core.Optim;
using ZeroNeural.Core.Loss;
using ZeroTensor.Core;
// Define model
var model = new Sequential(
new Linear(inFeatures: 4, outFeatures: 16),
new ReLU(),
new Linear(inFeatures: 16, outFeatures: 2)
);
var optimizer = new AdamW(model.Parameters(), lr: 0.01f);
var criterion = new CrossEntropyLoss();
// Training step
var xTrain = Tensor.RandomUniform(32, 4);
var yTrain = Tensor.Create(new[] { 32 }, new int[] { /* target classes */ });
optimizer.ZeroGrad();
var pred = model.Forward(xTrain);
var loss = criterion.Compute(pred, yTrain);
loss.Backward();
optimizer.Step();
Console.WriteLine($"Epoch Loss: {loss.Value:F4}");
๐ Benchmark & Performance
Tested on Intel Core i7-13700K (Release x64):
| Task | Configuration | Time / Epoch | Memory Overhead |
|---|---|---|---|
| Autograd Backward Pass | $1000$ operations DAG | $0.18 \text{ ms}$ | Linear tape memory |
| MLP Training ($32 \times 64 \times 10$) | Batch 128, Forward + Backward + Adam | $1.42 \text{ ms}$ | Reusable gradient buffers |
| Conv2D Forward + Backward | $3 \times 32 \times 32 \to 16 \times 30 \times 30$ | $8.60 \text{ ms}$ | Cache-tiled SIMD |
๐ License
MIT License ยฉ 2026 Phong Vรต. Part of the ZeroPlatform project.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- System.Buffers (>= 4.5.1)
- System.Memory (>= 4.5.5)
- System.Numerics.Vectors (>= 4.5.0)
- System.Runtime.CompilerServices.Unsafe (>= 6.0.0)
- ZeroPrimitives.Core (>= 1.7.0)
- ZeroTensor.Core (>= 1.5.0)
-
.NETStandard 2.0
- System.Buffers (>= 4.5.1)
- System.Memory (>= 4.5.5)
- System.Numerics.Vectors (>= 4.5.0)
- System.Runtime.CompilerServices.Unsafe (>= 6.0.0)
- ZeroPrimitives.Core (>= 1.7.0)
- ZeroTensor.Core (>= 1.5.0)
-
net8.0
- ZeroPrimitives.Core (>= 1.7.0)
- ZeroTensor.Core (>= 1.5.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ZeroNeural.Core:
| Package | Downloads |
|---|---|
|
ZeroAgent.Dialog
Deterministic Semantic Task-Oriented Dialogue System and Multi-Tier Agentic Memory Engine (Non-LLM) for ZeroAgent. |
GitHub repositories
This package is not used by any popular GitHub repositories.