ANN in Python, JavaScript & PHP

Neural networks graphicNowadays you see artificial intelligence (AI) everywhere. It suggests search terms in search fields, recognizes faces on photos, targets ads, and even gives “personality” to your smartphone/tablet.

One of the most common types of AI is the artificial neural network (ANN). As long as full-fledged neural devices with computing parallelism are not yet commonly accessible, building one on conventional computer architectures is fairly easy. Due to the resource-heavy training algorithms required by the most ANN structures, including the popular Feed-Forward Back Propagation NN (FFBP), it is better to build core ANN functionalities in low-level languages. However, there are a few options for using scripting languages. This is a short survey for my favourite scripting languages: Python, JavaScript, and PHP.


Fast and reliable, widely spread among computer scientists, Python has numerous libraries to deal with various ANN architectures.

PyBrain provides an extended infrastructure for machine-learning techniques. The vast palette of models available include back-propagation, unsupervised learning, recurrent networks, bidirectional networks, Kohonen self-organizing maps, and many more (not just ANN). PyBrain also empowers developers to create custom topologies, which gives it lots of flexibility.

Neurolab is much simpler but a good-to-know option, providing several of the more common topology classes (perceptrons, self-organizing maps, recurrent networks).

FANN (Fast Artificial Neural Network) does fewer things – but does them well. It is an implementation of FFBP perceptron written in C with interfaces to Python, PHP, and other languages. It also allows for Cascade learning, which means that the complexity of logic encapsulated in the NN is defined within the training process, not externally (as in the “classic” FFBP approach).


Synaptic is an awesome project, available for both server-side (NodeJS) and client-side implementations. It allows 4 basic topologies: perceptron, long short-term memory topology, liquid-state machines, and Hopfield recurrent NN. All are easy to build  and quite sufficient for most Web-related tasks. Just look at those demos on their site! NN-powered animation might still give your CPU a hard time, but you really can achieve an effect!


Naturally, PHP is the least attractive option to have ANN in, as normally PHP processes do not persist in memory, which costs more computational resources. Of course FANN, mentioned above, has a PHP interface, which makes it the #1 option due to C-based implementation. There are hardly any PHP-based implementations worth mentioning. Here’s just one:

ANN – Artificial Neural Network for PHP 5.x – gives a set of PHP libraries to build a multilayer perceptron. Though it is quite simplistic, it is capable of solving basic pattern recognition and prediction tasks.

In summary, the more CPU power an average server or client gets, the more unprecedented AI experience we can give to the user – at less cost.

1 thought on “ANN in Python, JavaScript & PHP

Comments are closed.