Module ImportFrom alias alias ImportFrom alias alias alias alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias alias ImportFrom alias Assign NameStore TupleLoad Str ClassDef bases NameLoad body Expr Str Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad FunctionDef arguments args NameParam defaults kwarg body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad keyword NameLoad Assign TupleStore NameStore NameStore AttributeLoad NameLoad attr Assign NameStore BinOpAdd AttributeLoad NameLoad attr NameLoad If AttributeLoad NameLoad attr body Assign NameStore Call NameLoad BinOpDiv NameLoad BinOpMult Num Call NameLoad NameLoad If CompareGt NameLoad NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Assign NameStore TupleLoad NameLoad NameLoad If CompareIs AttributeLoad NameLoad attr NameLoad body Assign AttributeStore NameLoad attr Call NameLoad NameLoad keyword NameLoad If CompareNotEq AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Expr Call NameLoad AttributeLoad NameLoad attr Call NameLoad Call NameLoad AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad Call NameLoad NameLoad keyword NameLoad If CompareEq AttributeLoad NameLoad attr Str body If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr Assign TupleStore NameStore NameStore AttributeLoad NameLoad attr Assign NameStore NameLoad For NameStore Call NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Num BinOpSub NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr ExtSlice Slice Index NameLoad Assign SubscriptStore NameLoad ExtSlice Slice Index NameLoad Call NameLoad NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Return Call AttributeLoad Call NameLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad keyword NameLoad Assign TupleStore NameStore NameStore AttributeLoad NameLoad attr If CompareEq NameLoad Num body Return Call NameLoad AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call NameLoad NameLoad For TupleStore NameStore NameStore Call NameLoad NameLoad body Assign SubscriptStore NameLoad Index NameLoad Call NameLoad AttributeLoad NameLoad attr NameLoad NameLoad Return NameLoad decorator_list decorator_list
N/A math log ceil numpy zeros fill_diagonal random sign neupy.utils format_data neupy.network.utils step neupy.core.properties Property utils bin2sign hopfield_energy base DiscreteMemory N/A __all__ N/A DiscreteHopfieldNetwork DiscreteHopfieldNetwork N/A DiscreteMemory N/A N/A  Discrete Hopfield Network. Memory algorithm which works only with
    binary vectors.

    Parameters
    ----------
    {DiscreteMemory.mode}
    {DiscreteMemory.n_times}
    check_limit : bool
        Option enable a limit of patterns control for the network using
        logarithmically proportion rule. Defaults to ``True``.

    Methods
    -------
    energy(input_data)
        Compute Discrete Hopfiel Energy.
    train(input_data)
        Save input data pattern into the network memory.
    predict(input_data, n_times=None)
        Recover data from the memory using input pattern.
        For the prediction procedure you can control number of iterations.
        If you set up this value equal to ``None`` then the value would be
        equal to the value that you set up for the property with
        the same name - ``n_times``.

    Notes
    -----
    * Input and output vectors should contain only binary values.

    Examples
    --------
    >>> import numpy as np
    >>> from neupy import algorithms
    >>>
    >>> def draw_bin_image(image_matrix):
    ...     for row in image_matrix.tolist():
    ...         print('| ' + ' '.join(' *'[val] for val in row))
    ...
    >>> 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
    ... ])
    >>>
    >>> two = np.matrix([
    ...     1, 1, 1, 0, 0,
    ...     0, 0, 0, 1, 0,
    ...     0, 0, 0, 1, 0,
    ...     0, 1, 1, 0, 0,
    ...     1, 0, 0, 0, 0,
    ...     1, 1, 1, 1, 1,
    ... ])
    >>>
    >>> 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,
    ... ])
    >>>
    >>> draw_bin_image(zero.reshape((6, 5)))
    |   * * *
    | *       *
    | *       *
    | *       *
    | *       *
    |   * * *
    >>> draw_bin_image(half_zero.reshape((6, 5)))
    |   * * *
    | *       *
    | *       *
    |
    |
    |
    >>> data = np.concatenate([zero, one, two], axis=0)
    >>>
    >>> dhnet = algorithms.DiscreteHopfieldNetwork()
    >>> dhnet.train(data)
    >>>
    >>> result = dhnet.predict(half_zero)
    >>> draw_bin_image(result.reshape((6, 5)))
    |   * * *
    | *       *
    | *       *
    | *       *
    | *       *
    |   * * *

    See Also
    --------
    :ref:`password-recovery`: Password recovery with Discrete Hopfield Network.
    :ref:`discrete-hopfield-network`: Discrete Hopfield Network tutorial.
     N/A check_limit N/A Property default True expected_type bool __init__ N/A N/A self N/A options N/A N/A N/A N/A N/A super DiscreteHopfieldNetwork self __init__ options N/A N/A self n_remembered_data 0 N/A train N/A N/A self input_data N/A N/A N/A N/A N/A self discrete_validation input_data N/A input_data N/A bin2sign input_data N/A input_data N/A format_data input_data is_feature1d False N/A N/A nrows n_features N/A input_data shape N/A nrows_after_update N/A N/A self n_remembered_data nrows N/A N/A self check_limit N/A N/A memory_limit N/A ceil N/A n_features N/A 2 N/A log n_features N/A N/A nrows_after_update memory_limit N/A N/A N/A ValueError N/A N/A You can't memorize more than {0} samples format memory_limit N/A weight_shape N/A n_features n_features N/A N/A N/A self weight None N/A N/A N/A self weight N/A zeros weight_shape dtype int N/A N/A N/A N/A self weight shape weight_shape N/A N/A N/A ValueError N/A N/A Invalid input shapes. Number of input features must be equal to {} and {} output features format weight_shape N/A N/A self weight N/A N/A N/A input_data T dot input_data N/A N/A fill_diagonal N/A self weight N/A zeros N/A len N/A self weight N/A N/A self n_remembered_data nrows_after_update N/A predict N/A N/A self input_data n_times N/A None N/A N/A N/A N/A self discrete_validation input_data N/A input_data N/A format_data N/A bin2sign input_data is_feature1d False N/A N/A N/A self mode async N/A N/A N/A n_times None N/A N/A n_times N/A self n_times N/A N/A _ n_features N/A input_data shape N/A output_data input_data N/A _ N/A range n_times N/A N/A position N/A N/A random randint 0 N/A n_features 1 N/A raw_new_value N/A N/A output_data dot N/A N/A self weight N/A N/A N/A position N/A N/A output_data N/A N/A N/A position N/A sign raw_new_value N/A N/A output_data N/A N/A input_data dot N/A self weight N/A N/A N/A N/A step output_data astype int N/A energy N/A N/A self input_data N/A N/A N/A N/A N/A self discrete_validation input_data N/A input_data N/A bin2sign input_data N/A input_data N/A format_data input_data is_feature1d False N/A N/A nrows n_features N/A input_data shape N/A N/A nrows 1 N/A N/A N/A hopfield_energy N/A self weight input_data input_data N/A output N/A zeros nrows N/A N/A i row N/A enumerate input_data N/A N/A N/A output N/A i N/A hopfield_energy N/A self weight row row N/A output N/A N/A