gradients
Deep Learning library using custos and custos-math.
external (C) dependencies: OpenCL, CUDA, nvrtc, cublas, a BLAS lib (OpenBLAS, Intel MKL, ...)
Installation
There are two features available that are enabled by default:
- cuda ... CUDA, nvrtc and cublas must be installed
- opencl ... OpenCL is needed
If you deactivate them (add default-features = false and provide no additional features), only the CPU device can be used.
For all feature-configurations, a BLAS library needs to be installed on the system.
[]
= "0.3.4"
# to disable the default features (cuda, opencl) and use an own set of features:
#gradients = {version = "0.3.4", default-features = false, features=["opencl"]}
MNIST example
(if this example does not compile, consider looking here)
Use a struct that implements the NeuralNetwork trait (it is implemented via the network attribute) to define which layers you want to use:
use ;
use OneHotMat;
use ;
Load data and create an instance of Network:
You can download the mnist dataset here.
// use cpu (no features enabled): let device = gradients::CPU::new().select();
// use cuda device (cuda feature enabled): let device = gradients::CudaDevice::new(0).unwrap().select();
// use opencl device (opencl feature enabled):
let device = new?;
let mut net = with_device;
let loader = new;
let loaded_data: = loader.load?;
let i = from;
let i = i / 255.;
let y = from;
let y = y.onehot;
Training loop:
let mut opt = new;
for epoch in range