neupy.algorithms.Kohonen

class neupy.algorithms.Kohonen[source]

Kohonen Neural Network used for unsupervised learning.

Parameters:
n_inputs : int

Number of features (columns) in the input data.

n_outputs : int

Number of outputs in the network.

weight : array-like, Initializer

Neural network weights. Value defined manualy should have shape (n_inputs, n_outputs). Defaults to Normal().

step : float

Learning rate, defaults to 0.1.

show_epoch : int

This property controls how often the network will display information about training. It has to be defined as positive integer. For instance, number 100 mean that network shows summary at 1st, 100th, 200th, 300th … and last epochs.

Defaults to 1.

shuffle_data : bool

If it’s True than training data will be shuffled before the training. Defaults to True.

signals : dict, list or function

Function that will be triggered after certain events during the training.

verbose : bool

Property controls verbose output in terminal. The True value enables informative output in the terminal and False - disable it. Defaults to False.

Examples

>>> import numpy as np
>>> from neupy import algorithms, layers, utils
>>>
>>> utils.reproducible()
>>>
>>> X = np.array([
...     [0.1961,  0.9806],
...     [-0.1961,  0.9806],
...     [0.9806,  0.1961],
...     [0.9806, -0.1961],
...     [-0.5812, -0.8137],
...     [-0.8137, -0.5812],
... ])
>>>
>>> kohonet = algorithms.Kohonen(
...     n_inputs=2,
...     n_outputs=3,
...     step=0.5,
...     verbose=False
... )
>>> kohonet.train(X, epochs=100)
>>> kohonet.predict(X)
array([[ 0.,  1.,  0.],
       [ 0.,  1.,  0.],
       [ 1.,  0.,  0.],
       [ 1.,  0.,  0.],
       [ 0.,  0.,  1.],
       [ 0.,  0.,  1.]])

Methods

predict(X) Predicts output for the specified input.
train(X_train, epochs=100) Train neural network.
fit(*args, **kwargs) Alias to the train method.
one_training_update(X_train, y_train)[source]

Function would be trigger before run all training procedure related to the current epoch.

Parameters:
epoch : int

Current epoch number.

options = {'n_inputs': Option(class_name='BaseAssociative', value=IntProperty(name="n_inputs")), 'n_outputs': Option(class_name='BaseAssociative', value=IntProperty(name="n_outputs")), 'show_epoch': Option(class_name='BaseNetwork', value=IntProperty(name="show_epoch")), 'shuffle_data': Option(class_name='BaseNetwork', value=Property(name="shuffle_data")), 'signals': Option(class_name='BaseNetwork', value=Property(name="signals")), 'step': Option(class_name='BaseNetwork', value=NumberProperty(name="step")), 'verbose': Option(class_name='Verbose', value=VerboseProperty(name="verbose")), 'weight': Option(class_name='BaseAssociative', value=ParameterProperty(name="weight"))}[source]
predict(X)[source]
predict_raw(X)[source]