eneural_net 2.0.0
eneural_net: ^2.0.0 copied to clipboard
AI Library to create efficient Artificial Neural Networks. Pure Dart + SIMD, portable to native, JS/Web, Wasm and Flutter, with optional Metal, CUDA and WebGPU acceleration.
2.0.0 #
-
Dart build hooks: the native libraries now build themselves. A new
hook/build.dartis run automatically by the Dart SDK ondart run,dart testanddart build. It compiles the native backend for the platform being built for and publishes each library as aCodeAsset, which thedart:ffi@Nativebindings resolve at runtime:Platform Assets Toolchain macOS package:eneural_net/eneural_cpu,package:eneural_net/eneural_metalswiftcLinux/Windows package:eneural_net/eneural_cudanvcc+ cuBLAS, only whennvccis onPATHNative acceleration therefore works for consumers of the package, not just inside a checkout of this repository — previously the libraries had to be built by hand and were only found relative to the working directory.
The hook never fails a build: when a toolchain is missing or a compile fails it emits no asset and training falls back to the pure-Dart SIMD path.
-
BREAKING —
dart compile exeno longer works for apps depending oneneural_net. The Dart SDK rejectsdart compile exefor any project with build hooks in its dependency graph ('dart compile' does not support build hooks, use 'dart build' instead.), regardless of platform and even where this hook produces nothing. Migrate todart build cli.Similarly,
dart test --compiler exeruns without the native code assets, because it compiles the test bootstrap outside the package. Usedart test --compiler cli. -
BREAKING — new required dependencies.
hooksandcode_assetsare now regular dependencies (build hooks run inside the resolution of depending packages, so they cannot be dev dependencies). -
Library loading is now two-stage: the code asset first, and — only when no library resolved at all — the previous working-directory search plus
DynamicLibrary.open. Libraries built by hand with the scripts undernative/keep working unchanged. -
The manual build scripts (
native/macos/build.sh,native/cuda/build.sh,native/cuda/build.bat,native/cuda/CMakeLists.txt) are retained for local/debug builds. The build hook is the primary path and mirrors their compiler flags.
1.7.3 #
- Opened the
intlupper bound further:>=0.18.1 <0.21.0→>=0.18.1 <2.0.0. Futureintl0.21+ and 1.x releases no longer require a neweneural_netrelease to be usable.
1.7.2 #
- Widened the
intlconstraint from^0.18.1to>=0.18.1 <0.21.0, so packages already onintl0.19.x or 0.20.x (including Flutter's pinned version) can depend oneneural_netwithout a resolution conflict. OnlyNumberFormat.decimalPatternis used, which is unchanged across those releases.
1.7.1 #
- WebGPU integration tests (browser GPU). New browser-only
test/eneural_net_webgpu_integration_test.dartexercising the real GPU path (WGSL compute shaders throughdart:js_interop) instead of the pure-Dart fallback:- Forward-pass parity with
ann.activate()over 6 topologies: bias / no bias, one and two hidden layers, and each supported activation function (Linear/Sigmoid/SigmoidFast/SigmoidBoundedFast). - Bit-exact weight upload/download round-trips, and Backpropagation/iRProp+ epochs differentially compared against the pure-Dart trainers.
- Multi-workgroup dispatch on larger networks, and the unsupported-network fallback.
- Compiling with
-DWEBGPU_REQUIRED=trueturns a missing WebGPU device into a failure instead of a skip, so a CI job cannot pass through the fallback path.
- Forward-pass parity with
dart_test.yaml: newwebgputag and thechrome_webgpu/chrome_webgpu_swiftshaderplatforms — the defaultchromeplatform is launched with--disable-gpu, which removesnavigator.gpuentirely.- CI: new
WebGPU CIworkflow running the integration tests with a required device on macOS (real GPU) and Linux (SwiftShader software adapter), plus a job covering the Dart VM / no-WebGPU fallback. test/eneural_net_webgpu_test.dart: added pure-Dart fallback assertions (the Dart VM is never accelerated, the fallback reproducesRPropexactly, andactivateWebGpureturnsnull).- Docs: README WebGPU requirements, what runs on the device, a "WebGPU tests" section and CI badges; the package description now mentions WebGPU.
- No library code changes: tests, test configuration, CI and docs only.
1.7.0 #
- NEW: CUDA (NVIDIA GPU) native backend for Windows/Linux (
native/cuda), added asNativeBackend.cuda. Same batched whole-epoch design as the Metal backend: the three per-layer GEMMs (forward / backprop / gradient) run on cuBLAS, and the activation/delta/Backpropagation/iRProp+ steps are CUDA kernels translated 1:1 from the pure-Dart numerics (incl. the bias-row = 1 rule), so weights read back match the Dart trainer withinfloat32tolerance. NativeBackend.autois now platform-aware: macOS picks CPU/Metal, Windows/Linux pick CUDA when available; requesting a backend not available on the host falls back to the pure-Dart SIMD path.- Build via
native/cuda/build.bat(Windows),native/cuda/build.sh(Linux), or CMake — requires the NVIDIA CUDA Toolkit (nvcc+ cuBLAS) and produceslibeneural_cuda_<arch>.{dll,so}.
1.6.1 #
- Examples: added
example/datasets/— runnable training examples on real, medium-size public datasets (UCI Optical Digits, Wine Quality regression, Letter Recognition 26-class classification), each with a selectable acceleration backend (none/auto/cpu/metal) that falls back to pure Dart, plus shared download/caching, per-column normalization, and accuracy helpers (example/datasets/common.dart). - Examples:
example/training_algorithms/with one runnable example per training algorithm, andexample/eneural_net_optimizers_example.dartfor the name-based registry and JSON checkpointing.
1.6.0 #
- NEW: Broad training-algorithm library (pure Dart). Adds many trainers
beyond Backpropagation/RProp, all SIMD
Float32x4:- Gradient optimizers via a new
GradientOptimizerseam:SGD(+momentum/Nesterov),Adam(+AdamW/Nadam/AMSGrad),RMSProp,AdaGrad,AdaDelta,Quickprop,Lion,ResilientPropagation(RProp+/RProp-/iRProp+/iRProp-). - Mini-batch / online training (
batchSize), L2 weight decay, gradient clipping, and LR schedules (step/exponential/cosine/warmup). - Second-order:
ConjugateGradient,LBFGS,LevenbergMarquardt. - Population / gradient-free:
EvolutionStrategy,SeparableCMAES,GeneticAlgorithm,ParticleSwarm,DifferentialEvolution,SimulatedAnnealing. - Dropout (per hidden layer via
HiddenLayerConfig, inverted, training-only). - Name-based registry (
trainingByName/registeredTrainings) and JSON checkpointing (saveTrainingCheckpoint/restoreTrainingCheckpoint). - New
SignalSIMD entry ops (sqrt/reciprocal/abs/min/max/clamp/scale/sign) andRandom.nextGaussian. - Additive-only to the existing pure-Dart/native/WebGPU paths (Backpropagation and RProp are unchanged).
- Gradient optimizers via a new
1.5.0 #
- NEW: WebGPU acceleration (browser GPU). Whole-epoch-on-device training in
the browser via WebGPU (WGSL compute shaders), batched like the Metal backend.
- New
WebGpuRProp/WebGpuBackpropagationtrainers (extendingRProp/BackpropagationonFloat32x4networks). Because WebGPU is asynchronous, training is driven byFuture-returning methods (trainUntilGlobalErrorAsync,trainAsync,activateWebGpu). - Reproduces the pure-Dart iRProp+/Backpropagation numerics. When WebGPU is unavailable (Dart VM, no browser WebGPU support, or an unsupported network) the async methods transparently fall back to the synchronous pure-Dart trainer, so the same code runs everywhere.
- Web-only code is behind a conditional import (
dart.library.js_interop), so the package still compiles for the Dart VM/native andpub publishis unaffected. - Added
example/eneural_net_webgpu_example.dartandtest/eneural_net_webgpu_test.dart.
- New
1.4.0 #
- NEW: Native acceleration (macOS CPU + Metal). Optional whole-epoch-on-device
training backends: Apple Accelerate (BLAS/vDSP, CPU) and Metal (GPU).
The network, weights, optimizer state and the full sample set are uploaded once
and each epoch runs entirely in native code (forward + backprop + weight
update), reproducing the pure-Dart iRProp+/Backpropagation numerics within
float32tolerance.- New drop-in trainers
NativeRPropandNativeBackpropagation(forFloat32x4networks), with aNativeBackendselector (auto/cpu/metal/none). - The package remains pure-Dart: web builds and
pub publishare unaffected; the trainers transparently fall back to the pure-Dart SIMD path when no native library is available or the network is unsupported. - Native libraries are built locally via
bash native/macos/build.sh(per-arch.dylib, git-ignored), loaded at runtime viadart:ffi. - The Metal backend is batched: all samples are processed at once, so each
epoch is a handful of
MetalPerformanceShadersGEMMs plus elementwise kernels (dispatch count independent of the sample count). On the64 -> 256 -> 16benchmark: CPU ~2.4x and Metal ~3.6x faster than pure Dart; the Metal lead grows with network size.autopicks CPU for small networks and Metal for large ones. - Added
example/eneural_net_benchmark_native.dartandexample/eneural_net_acceleration_example.dart, plustest/eneural_net_native_diff_test.dart(differential parity vs pure Dart).
- New drop-in trainers
1.3.2 #
-
FIX (Backpropagation/RProp): bias neurons propagate a constant
1in the forward pass, but the gradient computation used the value stored in the bias neuron slot instead. That value is0for the input layer andf(net)for hidden layers, so:- Input-layer bias weights received a zero gradient and never learned —
hidden neurons had no learnable input threshold (every hidden neuron output
was pinned to
0.5for a zero input). - Hidden-layer bias weights learned with a wrong-magnitude (but correct-sign) gradient.
The gradient now uses the bias neuron's true forward output (
1). Verified by numerical gradient checking: the analytical gradient now matches the central-difference gradient for every weight (cosine0.933 → 1.000), and networks converge faster and to a lower error.Added
test/eneural_net_backprop_gradient_test.dart(gradient-check harness). - Input-layer bias weights received a zero gradient and never learned —
hidden neurons had no learnable input threshold (every hidden neuron output
was pinned to
1.3.1 #
-
Test suite expanded from 24 to 565 tests, including integration tests. Line coverage: 84% -> 99.7%.
-
Signal:- FIX:
lastEntryLengthreturned a negative value for the implementations that allocate entries in chunks of 4 (SignalInt32x4andSignalFloat32x4Mod4), breakingcomputeSumSquares. - FIX:
setExtraValuesthrewStateErrorwhenever the padding was bigger than 3 values, which made anyInt32x4ANN impossible to build. - FIX:
SignalInt32x4.from/fromEntriesandSignalFloat32x4Mod4.fromEntriesproduced signals whose entries length was not a multiple of 4, breaking their unrolled SIMD loops. - FIX:
hashCodewas identity based while==was value based, so equal signals could not be used asSet/Mapkeys. - FIX:
SignalFloat32x4Mod4.copy()returned a plainSignalFloat32x4. - FIX:
SignalFloat32x4Mod4.calcEntriesCapacityForSizeignored the chunking. - FIX:
multiply,subtractandmultiplyEntriesreturned a signal ofcapacitylength instead oflength. - Added
valuesEntriesLength: the number of entries that hold values.
- FIX:
-
Scale:- FIX:
ScaleZoomableIntcould not be decoded from JSON (the emitted format name didn't matchScale.fromJson, andzoomwas never serialized).
- FIX:
-
ActivationFunction:- FIX:
ActivationFunctionSigmoidBoundedFast.activateEntry(SIMD) computed a different function thanactivate, and ignoredscale. - FIX:
ActivationFunctionSigmoidFastandActivationFunctionSigmoidBoundedFastadded theflat spotin the SIMD derivative but not in the scalar one. - FIX:
ActivationFunctionSigmoidFastInt.derivativeEntryused a hardcoded100instead ofscaleMax. - FIX:
createRandomWeightsignored itsscaleargument. - FIX:
byName/fromJsondidn't know theInt32x4functions, making theInt32x4branches ofANN.fromJsonunreachable. AddedscaleMaxtobyNameand toActivationFunctionSigmoidFastInt.toJsonMap.
- FIX:
-
ANN/Layer:- FIX: the "no bias neuron at the output layer" check never fired, silently adding an extra output neuron.
- FIX:
Layer.toJsonMap()threw on a layer that was not connected yet. - FIX:
resetWeightsleft the padding weights with random values.
-
Sample:- FIX:
proximityStatisticsused the input proximity twice, ignoring the output. - FIX:
SamplesSet.samplesSimilarityGroupsthrewRangeErrorwhen given asampleslist shorter than the set.
- FIX:
-
Training:- FIX: the
subjectparameter ofTraining/Backpropagation/RPropwas discarded. - FIX:
LearningRateStrategycould never recover the learning rate (the counter was reset on every call), and computed anInfinityinitial value before the training was initialized. - Added
bestTrainingErrorandresetBestTraining: a new training session no longer inherits the best weights of the previous one.
- FIX: the
-
DataStatistics:- FIX:
standardDeviationwas the RMS (the mean was never subtracted), disagreeing withList.standardDeviation. - FIX:
mean/standardDeviation/squaresMeanwereNaNfor an empty series. - Added
computeStandardDeviationandcomputeSquaresSum.
- FIX:
-
Chronometer:- FIX:
reset()didn't resetfailedOperations.
- FIX:
-
fast_math:- FIX:
expm1never wrote its high precision output, which madesinh(x)return0.0for every|x| <= 0.25. - FIX:
copySignignored the sign bit of-0.0, soatan2(-0.0, x)with a negativexreturned+piinstead of-pi. - FIX:
exp,expHighPrecision,expm1andatanthrewUnsupportedErroror returned a wrong finite value forNaN/infinities.
- FIX:
-
Extensions:
allEqualson an empty collection is now vacuouslytrue.- Added
List.plus(element-wise sum): the+operator of the extensions is shadowed byList.operator +(concatenation) and can never be reached through the operator syntax. Theclampextensions are likewise shadowed bynum.clampand are now documented as such.
1.3.0 #
-
Code reformatted with the new Dart formatter style (no behavior changes).
-
sdk: '>=3.10.0 <4.0.0'
-
collection: ^1.19.1
-
swiss_knife: ^3.1.6
-
test: ^1.31.2
1.2.0 #
-
Optimize & update Dart CI.
-
sdk: '>=3.0.0 <4.0.0'
-
collection: ^1.17.2
-
swiss_knife: ^3.1.5
-
intl: ^0.18.1
-
lints: ^2.1.1
-
test: ^1.24.6
-
dependency_validator: ^3.2.3
1.1.3 #
ANN:- Added
toJson,toJsonMapandfromJson.
- Added
Layer:- Added
toJson,toJsonMapandfromJson.
- Added
ActivationFunction:- Added
toJson,toJsonMap,fromJsonandbyName.
- Added
Scale:- Added
format. - Added
toJson,toJsonMapandfromJson.
- Added
Signal:- Added
formatandfromFormat. - Optimize
valuesimplementation for each format.
- Added
Propagationremove unused_layersPreviousGradientsDeltas.- Extension
ListExtension: - Added
asDoublesandasInts.
1.1.2 #
ActivationFunctionSigmoid:- Changed to use new faster
dart:math.expfunction.
- Changed to use new faster
1.1.1 #
ActivationFunction:- Added base class
ActivationFunctionFloat32x4. - SIMD Optimization:
- Improved performance in 2x.
ActivationFunctionLinear,ActivationFunctionSigmoid,ActivationFunctionSigmoidFast,ActivationFunctionSigmoidBoundedFast.
- Added base class
eneural_net_fast_math.dart:exp: Improved performance and input range bounded to -87..87.expFloat32x4: new SIMD Optimized Exponential function.
Chronometer:- Improved
toStringnumbers. Comparable.- operator
+.
- Improved
eneural_net_extensions:- Improved extensions.
- Improved documentation.
Training:- Added
logProgressEnabled.
- Added
- intl: ^0.17.0
1.1.0 #
ActivationFunction:- Added field
flatSpotforderivativeEntryWithFlatSpot(). - Added
ActivationFunctionLinear. ActivationFunctionSigmoid: activation with bounds (-700 .. 700).
- Added field
- Improved collections and numeric extensions.
- Improved
DataStatisticsand addCSVgenerator. Signal:- Added SIMD related operations.
- Added:
computeSumSquaresMean,computeSumSquares,valuesAsDouble. - Set extra values (out of length range):
setExtraValuesToZero,setExtraValuesToOne,setExtraValues. - Improved documentation.
Sample:- Input/Output statistics and proximity.
- Added
SamplesSet:- With per set computed
defaultTargetGlobalError. - Automatic
removeConflicts.
- With per set computed
Training:- Split into
PropagationandParameterStrategy, allowing other algorithms. - Added
Backpropagationwith SIMD, smart learning rate and smart momentum. - Added
iRprop+. - Added
TrainingLogger. - Added
selectInitialANN.
- Split into
ANN:- Optional bias neuron.
- Allow different
ActivationFunctionfor each layer.
1.0.2 #
- Expose fast math as an additional library.
1.0.1 #
README.md:- Improve text.
- Improve activation function text.
- Fix example.
1.0.0 #
- Initial version.
- Training algorithms: Backpropagation.
- Activation functions: Sigmoid and approximation versions.
- Fast math functions.
- SIMD: Float32x4