Introduction of neural-redis, part 1

The machine learning module for redis

Daniel
The Quarter Espresso
3 min readNov 8, 2016

--

Objective

Assuming you already know about Neural Network.

The neural-redis module provides an easy way to simulate a Multi-layer Neural Network that can do regression and classification, and it is designed to be native supported by redis server.

Create a neural network

If we are going to implement a neural network model that has 2 inputs, 1 hidden layer with 3 units, and 1 output as below:

Here are the steps:

  1. Clone unstable branch of redis-server and build it.
  2. Clone and build neural-redis, then load it via redis-server.
  3. Connect the server via redis-cli, and create the neural network (named as net) via the following command:

REGRESSOR means that given certain inputs and desired outputs.

NORMALIZE means that it is up to Redis to normalize the data it receives, so there is no need to provide data in the -/+ 1 range.

DATASET 50 and TEST 10 means that we want an internal memory for the dataset of 50 and 10 items respectively for the training dataset, and the testing dataset.

For more API reference including NR.CREATE you can refer to:
https://github.com/antirez/neural-redis#api-reference

The output 13 means the number of tunable parameters in the neural network.

Why 13?

In the neural network, we have input X, output Y, and hidden H:

Now for easily explanation, considering activation function:

And linear combination:

Which includes the weight A between input layer and hidden layer, weight B between hidden layer and output layer, and the bias/threshold Δ for the outputs:

The total number of these parameters is 13.

neural-redis is using RPROP algorithm by default.

For more information about the implementation, you can refer to: https://github.com/antirez/neural-redis/blob/master/nn.c

What is next?

Part 2 will show you how to train the neural network.

Reference

https://en.wikipedia.org/wiki/Artificial_neural_network

https://github.com/antirez/neural-redis/blob/master/README.md

https://en.wikibooks.org/wiki/Artificial_Neural_Networks/Activation_Functions

https://en.wikipedia.org/wiki/Artificial_neuron

https://en.wikipedia.org/wiki/Rprop

Other languages

中文: neural-redis簡介,第一部分

--

--