# Basics

NeuPy supports many different neural network types. These networks we can divide into two major categories.

1. Neural Networks with constructible architecture.
2. Neural Networks with fixed architecture.

Networks with constructible architecture is basically a field related to the deep learning. These algorithms allow us to construct different neural network architectures. Another type is networks with fixed architecture. There are many different classes like RBM, PNN, CMAC and so on. These networks have pre-defined architecture and there is no way to add or remove layers from it, but they have parameters that allow us to control them.

Despite the major differences between neural network algorithms the API for them looks very similar.

## Initialization

This is a first step to initialize the neural network. Each algorithm has its own set of parameters. Let’s check MinibatchGradientDescent algorithm as an example. Since most of the algorithms have lots of different parameters, NeuPy doesn’t support ordered arguments.

from neupy import algorithms

# Invalid initialization
gdnet = algorithms.MinibatchGradientDescent((2, 3, 1), 16, 'mae')

# Valid initialization
(2, 3, 1),
batch_size=16,
error='mae'
)


## Training

To train neural network we need to use train method.

from neupy import algorithms

nnet = algorithms.MinibatchGradientDescent((2, 3, 1))
nnet.train(x_train, y_train, epochs=1000)


If we need to validate our training results with validation dataset we can pass it as an additional argument.

from neupy import algorithms

nnet = algorithms.MinibatchGradientDescent((2, 3, 1))
nnet.train(x_train, y_train, x_test, y_test, epochs=1000)


To be able to see the output after each epoch we can set up verbose=True in the network initialization step.

from neupy import algorithms
nnet = algorithms.MinibatchGradientDescent((2, 3, 1), verbose=True)


Or we can switch on verbose parameter after the initialization.

from neupy import algorithms

nnet = algorithms.MinibatchGradientDescent((2, 3, 1))

nnet.verbose = True
nnet.train(x_train, y_train, x_test, y_test, epochs=1000)


## Prediction

To make a prediction we need to pass a dataset to the predict method.

y_predicted = nnet.predict(x_test)