• Stars
    star
    109
  • Rank 319,077 (Top 7 %)
  • Language
    Scala
  • Created over 10 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Scala library for neural networks

neuron Build Status Coverage Status

This project is a work-in-progress, which provides a flexible framework to experiment and run neural network of heterogeneous topologies. A preliminary release will be visible soon. neuron is written in Scala which adopts the so-called "define-by-run" scheme.

Features

  • template vs. module
  • neural network operators
  • autoencoders (w or w/o tiled weight)
  • activation functions: logistic, tanh, ReLU, softplus
  • metrics (L1, L2, Mahalanobis, Softmax)
  • regularization: weight decay, activation sparsity, dropout, maxout
  • data parallel framework: atomic parameters + distributed states
  • optimization: LBFGS, SGD, SAGD, SGD with momentum
  • recursive neural network

Documentation

The simplest example to train a regularized multi-layer perceptron to predict handwritten digits from MNIST dataset. It takes around ten minutes.

package neuron.examples

import neuron.core._
import neuron.math._

object MLP_MNIST extends Workspace with Optimizable {
    def main(args: Array[String]): Unit = {
      // set @MLP=784-200-10, @weight_decay=1E-4
      nn = (new RegularizedLinearNN(200, 10, 1E-4) **
            new SingleLayerNeuralNetwork(200) **
            new RegularizedLinearNN(784, 200, 1E-4)).create() // nn is declared in trait @Optimizable
            
      // load standard MNIST training data
      val (xData, yData) = LoadData.mnistDataM("std", "train")
      
      // generate random weight and initialize
      val theta0 = nn.getRandomWeights("get random weights").toWeightVector()
      nn.setWeights("set weight", theta0);
      
      // full-batch training (@maxIter=200, @distance=SoftMaxDistance)
      val (_, theta) = trainx(xData, yData, theta0, 200, SoftMaxDistance)
      
      // load standard MNIST testing data
      val (xDataTest, yDataTest) = LoadData.mnistDataM("std", "t10k")
      
      // estimate accuracy
      val accuracy = (yDataTest.argmaxCol() countEquals nn(xDataTest, null).argmaxCol()) / xDataTest.cols.toDouble
      println(accuracy)
    }
}
/* Accuracy: 0.9806 */

Also have a look at

  • Basics: explains the most fundamental ideas for the use of neuron, and why they featured neuron as a good choice for prototyping neural networks that leverage flexibility, simplicity and efficiency.
  • Auto-Encoder: a special family of unsupervised neural network.
  • Examples: we have more examples under folder src/main/scala/neuron/tutorials/
  • Scaladoc: TBA

FAQ

  • How is neuron different from other deep learning libraries (such as theano, torch7, etc), besides it is Scala based?

    We argue that not only the number of parameters contributes to the representation ability of neural network, but also its infrastructure (network topology, train strategy, etc.) Neuron focuses on fast prototyping novel network architecture. Using Scala, we attempt to make the implementation of neural network in a mixed functional and imperative way ... though neuron is not at the mature shape to be industrial proven.

  • How is the speed of neruon?

    Neuron is currently backed by breeze for numerical computation, which should be fast. And the extra cost for data control flow is minimized. Neuron provides convenient data parallelization.

Reference

  • Breeze and Nak: a set of libraries for machine learning and numerical computing
  • UFLDL Tutorial: a Stanford course, find solutions at Github
  • ScalaSTM: a lightweight software transactional memory for Scala

The MIT License (MIT)

Copyright (c) 2014 - 2015 Jianbo Ye

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

Decision_Tree_PDeque

C++ code for "A Faster Drop-in Implementation for Leaf-wise Exact Greedy Induction of Decision Tree Using Pre-sorted Deque"
C++
35
star
2

batchnorm_prune

Tensorflow codes for "Rethinking the Smaller-Norm-Less-Informative Assumption in Channel Pruning of Convolution Layers"
Python
30
star
3

WBC_Matlab

Efficient Wasserstein Barycenter in MATLAB (for "Fast Discrete Distribution Clustering Using Wasserstein Barycenter with Sparse Support" TSP)
MATLAB
25
star
4

acl2017_document_clustering

code for "Determining Gains Acquired from Word Embedding Quantitatively Using Discrete Distribution Clustering" ACL 2017
Python
21
star
5

OT_demo

demo codes for several approximate optimal transport solvers
MATLAB
20
star
6

100_NewMetho_CSPaper

100 new methodological papers in computer science
19
star
7

d2_kmeans

Fast discrete distributions clustering using Wasserstein barycenter with sparse support
C
12
star
8

scalaCART

Lightweight Yet Fast Scala implementation of CART
Scala
10
star
9

libffm-regression

C++
9
star
10

kaggle-bimbo

Kaggle: Grupo Bimbo Inventory Demand
C++
8
star
11

iMeshDeform

A C++ interactive mesh deformer
C
7
star
12

kaggle-redhat

Kaggle: Predicting Red Hat Business Value
Jupyter Notebook
6
star
13

GLBA

R code for Gated Latent Beta Allocation described in paper "Probabilistic Multigraph Modeling for Improving the Quality of Crowdsourced Affective Data", TAFFC
Jupyter Notebook
4
star
14

20newsgroups

Bash, Python, and Matlab Scripts to preprocess 20NG dataset
C
2
star
15

dmfCramer

Discrete Matrix Factorization with Cramer Risk Minimization
Scala
2
star
16

d2suite

A C++ package for discrete distribution based large-scale data processing framework
C++
2
star
17

ya-imagekit

Yet another image processing collections
C++
2
star
18

tri-mesh-toolkit

A toolkit for mesh (sequence) (pre-)processing, shape analysis and visualization
C++
2
star
19

md-scholar

A minimal, distraction-free Markdown editor for scholar. It currently support dynamically loading citations from DBLP and arXiv. It keeps notes for (manually) registered users. I personally use it for taking private notes.
JavaScript
2
star
20

slam1k1

1
star
21

kaggle-must-do

A must-do list for participating Kaggle competitions
1
star
22

renreNet

A force-directed graph of renren user's friends network (powered by d3.js)
JavaScript
1
star