Skip to content

A machine learning library in C++ with an emphasis on speed.

License

Notifications You must be signed in to change notification settings

quantumish/Jacobian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Banner

About

Jacobian is a work-in-progress machine learning library written in C++ designed to run as fast as possible while still being simple to use. Jacobian is accessible via Python and enables you to write models that train faster with the same amount of code. As of now, Jacobian supports feedforward neural networks and has partial support for convolutional neural networks.

Usage

Initializing and training a neural network with Jacobian takes just 8 lines of code!

import jacobian as jcb
net = jcb.Network("./data_banknote_authentication.txt", 10, 0.0155, 0.03, jcb.L2, 1, 0.9)
net.add_layer(4, jcb.activations.linear, jcb.activations.linear_deriv)
net.add_layer(5, jcb.activations.sigmoid, jcb.activations.sigmoid_deriv)
net.add_layer(2, jcb.activations.linear, jcb.activations.linear_deriv)
# Optional: net.init_optimizer(jcb.optimizers.momentum(0.1))
# Optional: net.init_decay(jcb.decays.exponential(1, 0.5))
net.initialize()
for i in range(50):
  net.train()

Examples

See example.cpp for an example of using Jacobian from C++, and example.py for an example of using Jacobian from Python.

Building

Dependencies

Eigen 3 is the only dependency, although building the python library requires pybind11.

Building with CMake

Don't forget to delete CMakeCache.txt after each compilation if you plan on switching things up!

There are two target languages, five main build configurations, and a number of toggleable build 'attributes'. The preferred target language can be specified by setting a CMake variable from the command-line: -DCXX=ON or -DPYTHON=ON.

The five main configurations correspond to differing levels of optimization.

  • cmake .: No compiler optimizations.
  • cmake . -DFAST=ON: Enables the O3 optimization layer in the compiler.
  • cmake . -DFASTER=ON: Enables O3 as well as extra individual flags.
  • cmake . -DTRADEOFFS=ON: All previous optimizations as well as ones that sacrifice precision.
  • cmake . -DRECKLESS=ON: Like TRADEOFFS, but defines the RECKLESS macro (and NDEBUG) which skips all checks within the code.

One you've selected a main optimization level, extra configurations can be passed in.

  • -DDEBUG=ON enables debugging features in the compiler (and shows warnings).

A sample build process would look like this:

rm CMakeCache.txt && cmake . -DPYTHON=ON -DFASTER=ON -DDEBUG=ON && make

About

A machine learning library in C++ with an emphasis on speed.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published