Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A simple library for creating complex neural networks

License

NotificationsYou must be signed in to change notification settings

ThoughtWorksInc/DeepLearning.scala

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepLearning.scalaThoughtWorks

Join the chat at https://gitter.im/ThoughtWorksInc/DeepLearning.scalaBuild StatusLatest versionScaladoc

DeepLearning.scala is a simple library for creating complex neural networks from object-oriented and functional programming constructs.

  • DeepLearning.scala runs on JVM, can be used either in standalone JVM applications or a Jupyter Notebooks.
  • DeepLearning.scala is expressive. Various types of neural network layers can be created by composingmap,reduce or other higher order functions.
  • DeepLearning.scala supports plugins. There are various plugins providing algorithms, models, hyperparameters or other features.
  • All the above features are statically type checked.

Features

Differentiable programming

Like other deep learning toolkits, DeepLearning.scala allows you to build neural networks from mathematical formulas. It supportsfloats,doubles,GPU-accelerated N-dimensional arrays, and calculates derivatives of the weights in the formulas.

Dynamic neural networks

Unlike some other deep learning toolkits, the structure of neural networks in DeepLearning.scala is dynamically determined during running. Our neural networks are programs. All Scala features, including functions, expressions and control flows, are available in neural networks.

For example:

defordinaryScalaFunction(a:INDArray):Boolean= {  a.signnum.sumT> math.random}defmyDynamicNeuralNetwork(input:INDArray)=INDArrayLayer(monadic[Do] {valoutputOfLayer1= layer1(input).forward.eachif (ordinaryScalaFunction(outputOfLayer1.data)) {    dynamicallySelectedLayer2(outputOfLayer1).forward.each  }else {    dynamicallySelectedLayer3(outputOfLayer1).forward.each  }})

The above neural network will go into different subnetworks according to an ordinary Scala function.

With the ability of creating dynamic neural networks, regular programmers are able to build complex neural networks from simple code. You write code almost as usual, the only difference being that code based on DeepLearning.scala is differentiable, which enables such code to evolve by modifying its parameters continuously.

Functional programming

DeepLearning.scala 2.0 is based on Monads, which are composable, thus a complex layer can be built from primitive operators or higher order functions likemap/reduce. Along with the Monad, we provide an Applicative type class, to perform multiple calculations in parallel.

For example, the previous example can be rewritten in higher-order function style as following:

defmyDynamicNeuralNetwork(input:INDArray)=INDArrayLayer {  layer1(input).forward.flatMap { outputOfLayer1=>if (ordinaryScalaFunction(outputOfLayer1.data)) {      dynamicallySelectedLayer2(outputOfLayer1).forward    }else {      dynamicallySelectedLayer3(outputOfLayer1).forward    }  }}

The key construct in DeepLearning.scala 2.0 is the dependent type classDeepLearning, which witnesses a differentiable expression. In other words, given theDeepLearning type class instance, you can activate the deep learning ability of any type.

Object-oriented programming

The code base of DeepLearning.scala 2.0 is organized according to Dependent Object Type calculus (DOT). All features are provided as mixin-able plugins. A plugin is able to change APIs and behaviors of all DeepLearning.scala types. This approach not only resolvesexpression problem, but also gives plugins the additional ability ofvirtually depending on other plugins.

For example, when a plugin author is creating theAdagrad optimizer plugin, he does not have to explicitly call functions related to learning rate. However, once a plugin user enables both theAdagrad plugin and theFixedLearningRate plugin, then computation inFixedLearningRate will get called eventually when theAdagrad optimization is executed.

Roadmap

v2.0

Version 2.0 is the current version with all of the above features.

v3.0

  • Support element-wisemap/reduce and other higher-order functions on GPU.
  • Support distributed models and distributed training onSpark.

Links

Acknowledgements

DeepLearning.scala is sponsored byThoughtWorks.

DeepLearning.scala is heavily inspired by my colleague@MarisaKirisame. Originally, we worked together on a prototype of a deep learning framework, and eventually split our work into this project andDeepDarkFantasy.Other contributors can be found athere.

Related projects

  • Shapeless provides a solid foundation for type-level programming used in DeepLearning.scala.
  • Scalaz andAlgebra provides type classes used in DeepLearning.scala.
  • ThoughtWorks Each providesasync/await-like syntax. You may want to use it to control your training process in an imperative style.
  • nd4j provides numerical computing used in DeepLearning.scala 2.0.
  • Compute.scala provides numerical computing used in DeepLearning.scala 3.0.
  • RAII.scala,future.scala andtryt.scala provides monadic asynchronous resource management used in DeepLearning.scala.
  • Plugins of DeepLearning.scala are based onFactory and other dependent type classes infeature.scala.
  • Import.scala is a Scala compiler plugin that enables magic imports. You may need it in those sbt project use DeepLearning.scala plugin hosted on Github Gist.
  • DeepLearning.scala can run inJupyter Scala orAmmonite.
  • The unit tests of DeepLearning.scala are written inScalaTest andexample.scala syntax.
  • Some type classes in DeepLearning.scala are created bysimulacrum's@typeclass annotation.

[8]ページ先頭

©2009-2025 Movatter.jp