Crate drug[][src]

∂rug - Differentiable Rust Graph

This crate is a collection of utilities to build build neural networks (differentiable programs). See examples source code for implementations of canonical neural networks. You may need to download those datasets yourself to use them. Examples include:

  • Mnist with dense networks
  • Mnist with convolutional neural networks (though embarassingly slowly)
  • Penn TreeBank character prediction with RNN and GRU

Planned Changes

  • Saving / loading
    • Naming and indexing via string
  • Building complexes of nodes (conv + bias + relu) / RNN cells, with parameter reuse
  • Subgraphs / updating subsets of graphs (e.g. for GAN)
  • Parallel backprop multiple arguments of 1 node
  • ndarray-parallel usage

Reinforcement learning applications may also challenge the archiecture but I don't understand the process well enough yet to consider adding it to the library.

Wish list

  • GPU integration (awaiting advancements in rust gp-gpu)
  • Operator overloading API + Taking advantage of the type system and const generics
    • May require total overhaul.. or may be possible with a "Graph Cursor" trait and more sophisticaed handles beyond current Idxs
  • Automatic differentiation of operations defined only from loops (proc macros?)
  • Distributed training
  • Other kinds of derivatives e.g. jacobian

Re-exports

pub extern crate ndarray;
pub use nodes::Node;

Modules

nodes

This module holds the different types nodes that exist in a computation graph.

optimizers

This module holds the various optimizers used to update parameters in a computation graph. Currently only one is implemented.

Structs

Graph

A differentiable computation graph. Use this struct to hold your differentiable program which is a directed acyclic graph of Nodes, their associated values and losses (gradients). The graph computes values moving forward in insertion order (see forward method) and propagates losses backwards in reverse insertion order (see backward method). The default graph comes with an xavier initializer and a vanilla stochastic gradient descent optimizer.

Idx

A placeholder to help index into a graph. These should not be interchanged between graphs.

Enums

GlobalPool

Type of pooling operation (only supports average). Implements Operation. See Node constructor for full description.

Padding

Type of padding to use in a convolutional neural network. No padding means a non-strided convolution will shrink by the dimensions of the kernel as pixels at the edge will not be the center of a convolution. Same padding allows for convolution of edge pixels by assuming the values beyond the images are equal to the edge. Other not implemented padding strategies are "Zero" padding or "Reflection" padding.

Functions

softmax

Take the softmax of an array of shape batch_size * num_classes

softmax_cross_entropy_loss

A loss function used for classification.

xavier_initialize

The default (and only provided) initializer. Only works with convolution kernels and matrices.