neupy.algorithms.memory.bam module

class neupy.algorithms.memory.bam.DiscreteBAM[source]

Discrete BAM Network with associations. Network associate every input with some target value.

Parameters:

mode : {sync, async}

Indentify pattern recovery mode.

  • sync mode tries to recover pattern using all values from the input vector.
  • async mode choose randomly some values from the input vector and iteratively repeat this procedure. Number of iterations defines by the n_times parameter.

Defaults to sync.

n_times : int

Available only in async mode. Identify number of random trials. Defaults to 100.

Notes

  • Input and output vectors should contain only binary values.

Examples

>>> import numpy as np
>>> from neupy import algorithms
>>>
>>> zero = np.matrix([
...     0, 1, 1, 1, 0,
...     1, 0, 0, 0, 1,
...     1, 0, 0, 0, 1,
...     1, 0, 0, 0, 1,
...     1, 0, 0, 0, 1,
...     0, 1, 1, 1, 0
... ])
>>>
>>> one = np.matrix([
...     0, 1, 1, 0, 0,
...     0, 0, 1, 0, 0,
...     0, 0, 1, 0, 0,
...     0, 0, 1, 0, 0,
...     0, 0, 1, 0, 0,
...     0, 0, 1, 0, 0
... ])
>>> zero.reshape((5, 6))
>>>
>>> half_zero = np.matrix([
...     0, 1, 1, 1, 0,
...     1, 0, 0, 0, 1,
...     1, 0, 0, 0, 1,
...     0, 0, 0, 0, 0,
...     0, 0, 0, 0, 0,
...     0, 0, 0, 0, 0,
... ])
>>>
>>> zero_hint = np.matrix([[0, 1, 0, 0]])
>>> one_hint = np.matrix([[1, 0, 0, 0]])
>>>
>>> data = np.concatenate([zero, one], axis=0)
>>> hints = np.concatenate([zero_hint, one_hint], axis=0)
>>>
>>> bamnet = algorithms.DiscreteBAM(mode='sync')
>>> bamnet.train(data, hints)
>>>
>>> recovered_zero, recovered_hint = bamnet.predict(half_zero)
>>> recovered_hint
matrix([[0, 1, 0, 0]])
>>>
>>> zero_hint
matrix([[0, 1, 0, 0]])

Methods

train(input_data, output_data) Train network and update network weights.
predict_output(input_data, n_times=None) Using input data recover output data. Returns two arguments. First is an input data, second is an output data.
predict(input_data, n_times=None) Alias to the predict_output method.
predict_input(output_data, n_times=None) Using output data recover input data. Returns two arguments. First is input data, second is output data.
energy(input_data, output_data) Calculate Hopfiel Energy for the input and output data.
energy(input_data, output_data)[source]
format_predict(predicted_result)[source]
options = {'verbose': Option(class_name='Verbose', value=VerboseProperty(name="verbose")), 'n_times': Option(class_name='DiscreteMemory', value=IntProperty(name="n_times")), 'mode': Option(class_name='DiscreteMemory', value=ChoiceProperty(name="mode"))}[source]
predict(input_data, n_times=None)[source]
predict_input(output_data, n_times=None)[source]
predict_output(input_data, n_times=None)[source]
prediction(input_data=None, output_data=None, n_times=None)[source]
train(input_data, output_data)[source]