Designing a neural network in Java or any other programming language requires an understanding of the structure and functionality of artificial neural networks.

Artificial neural networks perform tasks such as pattern recognition, learning from data, and forecasting trends just like an expert can, as opposed to the conventional algorithmic approach that requires a set of steps to be performed to achieve the defined goal. An ANN can learn how to solve some task by itself because of its highly interconnected network structure.

The artificial neuron has a similar structure to the neurons of the human brain. A natural neuron is composed of a nucleus, dendrites, and axons. The axon extends itself into several branches to form synapses with other neurons' dendrites.

So far, we have identified the structure of a neuron and the network of connected neurons. Another important aspect is the processing or calculations associated with a neural network respectively with a single neuron. Natural neurons are signal processors — they receive micro signals in the dendrites that can trigger a signal in the axon. There is a threshold potential that, when reached, fires the axon and propagates the signal to the other neurons. Therefore, we can then think of an artificial neuron as having a signal collector in the inputs and an activation unit in the output that can trigger a signal that will be forwarded to other neurons similar to the one shown on the picture:

Furthermore, the connections between neurons have associated weights that can modify the signals, thus influencing on the neuron's output. Since the weights are internal to the neural network and influence its outputs, they can be considered to be the neural network's internal knowledge. Adjusting weights that characterize the neuron's connections to other neurons or to the external world will reflect the neural networks capabilities.

The artificial neuron receives one or more inputs (representing dendrites) and sums them up to produce an output/
activation (representing a neuron's axon). Usually, the sums of each node are weighted and the sum is passed through an activation function or transfer function.

This component adds nonlinearity to neural network processing, which is needed because the natural neuron has nonlinear behaviors. In some special cases, it can be a linear function.

A standard computer chip circuit can be seen as a digital network of activation functions that can be "ON" (1) or "OFF" (0), depending on input. This is similar to the behavior of the linear perceptron in neural networks. However, it is the
nonlinear activation function that allows such networks to compute nontrivial problems using only a small number of nodes. Examples of popular activation functions used are Sigmoid, hyperbolic tangent, hard limiting threshold, and purely linear.

Translating this knowledge into Java code, we will have a neuron class as follows:

The last aspect that needs attention before starting to write code is neural network layers. Neural networks can be composed of several linked layers, forming the so-called multilayer networks. The neural layers can be divided into three classes:

Input layer

Hidden layer

Output layer

In practice, an additional neural layer adds another level of abstraction of the outside stimuli, enhancing the neural network's capacity to represent more complex knowledge.

A layer class can be defined as a list of neurons having their connections:

What we achieved is a structural definition of a Java-based neural network with layers, neurons, and connections. We also talked a bit about the activation functions and defined an interface for them. For simplicity, we omitted the implementation of various activation functions and the basics of learning neural networks. These two topics will be presented in subsequent articles of this series.

Adopting a digital strategy is just the beginning. For enterprise-wide digital transformation to truly take effect, you need an infrastructure that’s #BuiltOnAI. Click here to learn more.