neupy.algorithms.associative.kohonen module

class neupy.algorithms.associative.kohonen.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 or str

This property controls how often the network will display information about training. There are two main syntaxes for this property.

  • You can define it as a positive integer number. It defines how offen would you like to see summary output in terminal. For instance, number 100 mean that network shows summary at 100th, 200th, 300th ... epochs.
  • String defines number of times you want to see output in terminal. For instance, value '2 times' mean that the network will show output twice with approximately equal period of epochs and one additional output would be after the finall epoch.

Defaults to 1.

shuffle_data : bool

If it’s True class shuffles all your training data before training your network, defaults to True.

epoch_end_signal : function

Calls this function when train epoch finishes.

train_end_signal : function

Calls this function when train process finishes.

verbose : bool

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

Examples

>>> import numpy as np
>>> from neupy import algorithms, layers, environment
>>>
>>> environment.reproducible()
>>>
>>> input_data = 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(input_data, epochs=100)
>>> kohonet.predict(input_data)
array([[ 0.,  1.,  0.],
       [ 0.,  1.,  0.],
       [ 1.,  0.,  0.],
       [ 1.,  0.,  0.],
       [ 0.,  0.,  1.],
       [ 0.,  0.,  1.]])

Methods

predict(input_data) Predicts output for the specified input.
train(input_train, summary=’table’, epochs=100) Train neural network.
fit(*args, **kwargs) Alias to the train method.
options = {'verbose': Option(class_name='Verbose', value=VerboseProperty(name="verbose")), 'step': Option(class_name='BaseNetwork', value=NumberProperty(name="step")), 'show_epoch': Option(class_name='BaseNetwork', value=ShowEpochProperty(name="show_epoch")), 'shuffle_data': Option(class_name='BaseNetwork', value=Property(name="shuffle_data")), 'epoch_end_signal': Option(class_name='BaseNetwork', value=Property(name="epoch_end_signal")), 'train_end_signal': Option(class_name='BaseNetwork', value=Property(name="train_end_signal")), 'n_inputs': Option(class_name='BaseAssociative', value=IntProperty(name="n_inputs")), 'n_outputs': Option(class_name='BaseAssociative', value=IntProperty(name="n_outputs")), 'weight': Option(class_name='BaseAssociative', value=ParameterProperty(name="weight"))}[source]
predict(input_data)[source]

Return prediction results for the input data.

Parameters:input_data : array-like
Returns:array-like
predict_raw(input_data)[source]
train_epoch(input_train, target_train)[source]