Neural networks in Haskell - advice - haskell

Can anybody suggest me tutorial, book, blog or share code sample for neural networks in Haskell ? I have experience in neural networks in imperative languages, but I want try that in Haskell.

There are several libraries on Hackage:
HaskellNN A Haskell library which uses hmatrix (and, transitively, GSL and libLBFGS C libraries) to do heavy lifting (GPL). Claims to be fast.
instinct A pure-Haskell library which claims to be fast (BSD).
hnn A minimal Haskell Neural Network Library (LGPL).
bindings-fann Bindings to FANN library.
hfann Other bindings to FANN library.

You may find this sample application useful. It uses back-propagation. I wrote an article discussing the example, explaining how the use of a functional paradigm affects the design. The article should appear in the next issue of The Monad Reader.

The DataHaskell community keeps a more up-to-date list of Hackage packages at http://www.datahaskell.org/docs/community/current-environment.html#neural-networks
As of 2019-08-26, it recommends these packages:
neural (CPU-only, see issue 10)
backprop-learn uses the backprop library (CPU-only?)
grenade (dependently typed! Comfortable API, but CPU-only so far, see issue 55 / issue 35 / issue 6)
hasktorch (Haskell bindings to the C libs underlying PyTorch, early development but it should let you train on GPU)
tensorflow (Haskell bindings to TF; most likely what you'd use in production, but intimidating API; can run on GPU)
(and sibe (CPU-only), though under the ML heading, implements neural networks)
There's a series of blog posts on using TensorFlow from Haskell at https://mmhaskell.com/blog/2017/8/14/starting-out-with-haskell-tensor-flow / https://mmhaskell.com/blog/2017/8/21/digging-in-deep-solving-a-real-problem-with-haskell-tensor-flow etc.
If you're interested in autograd/differentiable programming, the backprop-learn author shows how to add dependent types to a neural network and how to do automatic differentiation (as in TF) from Haskell, which is what eventually turned into the backprop library. See also the ad library (quick demo here).

Related

Can JAGS (Just Another Gibbs Sampler) deal with ordinary differential equations?

I searched about the JAGS's manual and one post (here in 2012) about the ordinary differential equation (ode). I was thinking JAGS can because it's similar to WinBUGS (which does it through WBdiff interface). However, if I let JAGS read in my ode code, it cannot even recognize the D(y[...], t) expression.
Can JAGS deal with ode? Maybe I missed a plug-in in JAGS like WBdiff?
While WinBUGS/OpenBUGS/JAGS have almost equivalent syntax/feature sets, there are a few differences between them: one of these is that there is no ODE solver included as part of a standard JAGS installation.
However, JAGS is extensible using user-specified modules (like the plug-ins you mentioned), which provide new functions/distributions using C++ code that can then be used within JAGS when that module is loaded. It would certainly be possible to implement an ODE this way using e.g. the ODE solvers included in the boost C++ library. To do so you will need the following:
Familiarity with C++
Instructions for how to build a module for JAGS
I can't help you with the former, so this may be a dead-end for you if you have never used C++ before. But there is a tutorial available for how to build a JAGS module: https://pubmed.ncbi.nlm.nih.gov/23959766/ This article shows how to build a standalone module, but if you are happy to accept the limitation of using JAGS from R (as most people do) then it is MUCH easier to build a JAGS module within an R package - you could follow code in the runjags package as an example https://cran.r-project.org/package=runjags
If you are thinking of trying to do this yourself then I could potentially help with a few pointers along the way. Of course, it is also possible that someone else has already done this, but if so then I am not aware of it.

Does the ojAlgo matrix library supports multi-threading?

I am working on a project that requires inversion of multiple large dense matrix. I would like to know if ojAlgo supports multi-threading.
I do notice the github page for ojAlgo is tagged with multi-threading, however I am unable to find any documentation about it.
Thanks

vDSP equivalent for Linux

I have had good experiences with Apple's vDSP primitives under OS X and iOS.
http://developer.apple.com/library/mac/#documentation/Accelerate/Reference/vDSPRef/Reference/reference.html
Now I am trying to port some code that relies on vDSP to Linux and I wonder if any equivalents are available built into one of the standard libraries.
While there is not presently any library that matches vDSP, there are several alternatives you might explore. A couple off the top of my head:
OpenCV is an impressive collection of image processing and computer vision
routines with a vibrant user and research community.
Eigen is a C++11 template library for linear algebra:
matrices, vectors, numerical solvers, and related algorithms.
My personal recommendation would be Eigen.

Graph and Network Library for Haskell

Any suggestions for a good graph and network library for Haskell ?
I'm looking on functionality something like which networkx library has for Python.
I've found fgl (also see home page) quite easy to work with. I'm not familiar with networkx, so I don't know how it compares.
There's a graph data-structure in the containers package. You can view the interface for it here.
Additionally, you can search through all of the packages available on the haskell-platform or additional packages through Cabal using Hayoo!
It's more than a year old question, but in case someone looks for the lib - the igraph package provides the bindings to all functions about graph properties of the igraph-C library. It won't compile with the igraph-C versions newer than 0.6.5, because the authors don't have time to maintain it, as Nils Schweinsberg said: Pull requests are wellcome. Also not all functions from the original library have the Haskell bindings, but one can write some using the FFI.
fgl is very beautiful library implementing the functional concept of inductive graphs, but it lacks the functionality of the igraph library: You can create directed/undirected weighted/unweighted graphs and have the algorithms implemented taking that into account.
The igraph package could be a very valuable library for the Haskell community if an experienced haskeller took care of it further.

High-level level language for image processing

My final year project group is planning to build a real time application with neural network support and need to handle image processing efficiently, Any language suggestions would be very much helpful. Thanks.
Mathematica may offer some useful features. The last couple of releases have added quite a lot of image processing functionality. You can get a taste by looking at these blog entries:
How to Make a Webcam Intruder Alarm with Mathematica
The Battle of the Marlborough Maze at Blenheim Palace Continues
The Incredible Convenience of Mathematica Image Processing
Mathematica is an interpreted language, which would appear to present an obstacle to your real-time constraints. However, Mathematica has always integrated well will foreign code (notably C, Java and .NET) and the latest release adds considerable new capabilities with respect to C-code generation, dynamic-library loading and CUDA / OpenCL GPU programming.
Alas, Mathematica is not FOSS and is pretty expensive for commercial use. However, they give great student discounts (90%+, last time I checked) and some college/university departments have site licenses.
On the down side, the Mathematica language is quite unconventional and it takes time to get into the swing of things. IMO, the effort is worth it, but the learning curve might be too long if your project timelines are short.
Note: I am not affiliated with WRI in any way.
My suggestion is OpenCV and C++. OpenCV is also usable with Python, but I don't recommend it if you need to write fast code, Python can be really slow.
How about Python? There is PIL, which
adds image processing capabilities to your Python interpreter. This library supports many file formats, and provides powerful image processing and graphics capabilities.
An introductory article about NN with python and a feed forward NN library:
http://www.ibm.com/developerworks/library/l-neurnet/
http://pypi.python.org/pypi/ffnet/0.6
Matlab provides a lot of features for image processing. May be slightly slow, but I assume performance is not an issue.
ImageMagick is suppose to be real good, but I have no first-hand experience. Mathematica?

Resources