class_docstr: Self-Organizing Feature Map (SOFM or SOM).
  
  Notes
  -----
  - Training data samples should have normalized features.
  
  Parameters
  ----------
  {BaseAssociative.n_inputs}
  
  n_outputs : int or None
      Number of outputs. Parameter is optional in case if
      ``feature_grid`` was specified.
  
      .. code-block:: python
  
          if n_outputs is None:
              n_outputs = np.prod(feature_grid)
  
  learning_radius : int
      Parameter defines radius within which we consider all
      neurons as neighbours to the winning neuron. The bigger
      the value the more neurons will be updated after each
      iteration.
  
      The ``0`` values means that we don't update
      neighbour neurons.
  
      Defaults to ``0``.
  
  std : int, float
      Parameters controls learning rate for each neighbour.
      The further neighbour  neuron from the winning neuron
      the smaller that learning rate for it. Learning rate
      scales based on the factors produced by the normal
      distribution with center in the place of a winning
      neuron and standard deviation specified as a parameter.
      The learning rate for the winning neuron is always equal
      to the value specified in the ``step`` parameter and for
      neighbour neurons it's always lower.
  
      The bigger the value for this parameter the bigger
      learning rate for the neighbour neurons.
  
      Defaults to ``1``.
  
  features_grid : list, tuple, None
      Feature grid defines shape of the output neurons.
      The new shape should be compatible with the number
      of outputs. It means that the following condition
      should be true:
  
      .. code-block:: python
  
          np.prod(features_grid) == n_outputs
  
      SOFM implementation supports n-dimensional grids.
      For instance, in order to specify grid as cube instead of
      the regular rectangular shape we can set up options as
      the following:
  
      .. code-block:: python
  
          SOFM(
              ...
              features_grid=(5, 5, 5),
              ...
          )
  
      Defaults to ``(n_outputs, 1)``.
  
  grid_type : {{``rect``, ``hexagon``}}
      Defines connection type in feature grid. Type defines
      which neurons we will consider as closest to the winning
      neuron during the training.
  
      - ``rect`` - Connections between neurons will be organized
        in hexagonal grid.
  
      - ``hexagon`` - Connections between neurons will be organized
        in hexagonal grid. It works only for 1d or 2d grids.
  
      Defaults to ``rect``.
  
  distance : {{``euclid``, ``dot_product``, ``cos``}}
      Defines function that will be used to compute
      closest weight to the input sample.
  
      - ``dot_product``: Just a regular dot product between
        data sample and network's weights
  
      - ``euclid``: Euclidean distance between data sample
        and network's weights
  
      - ``cos``: Cosine distance between data sample and
        network's weights
  
      Defaults to ``euclid``.
  
  reduce_radius_after : int or None
      Every specified number of epochs ``learning_radius``
      parameter will be reduced by ``1``. Process continues
      until ``learning_radius`` equal to ``0``.
  
      The ``None`` value disables parameter reduction
      during the training.
  
      Defaults to ``100``.
  
  reduce_step_after : int or None
      Defines reduction rate at which parameter ``step`` will
      be reduced using the following formula:
  
      .. code-block:: python
  
          step = step / (1 + current_epoch / reduce_step_after)
  
      The ``None`` value disables parameter reduction
      during the training.
  
      Defaults to ``100``.
  
  reduce_std_after : int or None
      Defines reduction rate at which parameter ``std`` will
      be reduced using the following formula:
  
      .. code-block:: python
  
          std = std / (1 + current_epoch / reduce_std_after)
  
      The ``None`` value disables parameter reduction
      during the training.
  
      Defaults to ``100``.
  
  weight : array-like, Initializer or {{``init_pca``, ``sample_from_data``}}
      Neural network weights.
      Value defined manualy should have shape ``(n_inputs, n_outputs)``.
  
      Also, it's possible to initialized weights base on the
      training data. There are two options:
  
      - ``sample_from_data`` - Before starting the training will
        randomly take number of training samples equal to number
        of expected outputs.
  
      - ``init_pca`` - Before training starts SOFM will applies PCA
        on a covariance matrix build from the training samples.
        Weights will be generated based on the two eigenvectors
        associated with the largest eigenvalues.
  
      Defaults to :class:`Normal() <neupy.init.Normal>`.
  
  {BaseNetwork.step}
  
  {BaseNetwork.show_epoch}
  
  {BaseNetwork.shuffle_data}
  
  {BaseNetwork.signals}
  
  {Verbose.verbose}
  
  Methods
  -------
  init_weights(train_data)
      Initialized weights based on the input data. It works only
      for the `init_pca` and `sample_from_data` options. For other
      cases it will throw an error.
  
  {BaseSkeleton.predict}
  
  {BaseAssociative.train}
  
  {BaseSkeleton.fit}
  
  Examples
  --------
  >>> import numpy as np
  >>> from neupy import algorithms, utils
  >>>
  >>> utils.reproducible()
  >>>
  >>> data = np.array([
  ...     [0.1961, 0.9806],
  ...     [-0.1961, 0.9806],
  ...     [-0.5812, -0.8137],
  ...     [-0.8137, -0.5812],
  ... ])
  >>>
  >>> sofm = algorithms.SOFM(
  ...     n_inputs=2,
  ...     n_outputs=2,
  ...     step=0.1,
  ...     learning_radius=0
  ... )
  >>> sofm.train(data, epochs=100)
  >>> sofm.predict(data)
  array([[0, 1],
         [0, 1],
         [1, 0],
         [1, 0]])
class_docstr_tok: ["Self-Organizing","Feature","Map","(","SOFM","or","SOM",")",".","Notes","--","--","-","-","Training","data","samples","should","have","normalized","features",".","Parameters","--","--","--","--","--","{","BaseAssociative.n_inputs","}","n_outputs",":","int","or","None","Number","of","outputs",".","Parameter","is","optional","in","case","if","``","feature_grid","``","was","specified",".","..","code-block",":",":","python","if","n_outputs","is","None",":","n_outputs","=","np.prod","(","feature_grid",")","learning_radius",":","int","Parameter","defines","radius","within","which","we","consider","all","neurons","as","neighbours","to","the","winning","neuron",".","The","bigger","the","value","the","more","neurons","will","be","updated","after","each","iteration",".","The","``","0","``","values","means","that","we","do","n't","update","neighbour","neurons",".","Defaults","to","``","0","``",".","std",":","int",",","float","Parameters","controls","learning","rate","for","each","neighbour",".","The","further","neighbour","neuron","from","the","winning","neuron","the","smaller","that","learning","rate","for","it",".","Learning","rate","scales","based","on","the","factors","produced","by","the","normal","distribution","with","center","in","the","place","of","a","winning","neuron","and","standard","deviation","specified","as","a","parameter",".","The","learning","rate","for","the","winning","neuron","is","always","equal","to","the","value","specified","in","the","``","step","``","parameter","and","for","neighbour","neurons","it","'s","always","lower",".","The","bigger","the","value","for","this","parameter","the","bigger","learning","rate","for","the","neighbour","neurons",".","Defaults","to","``","1","``",".","features_grid",":","list",",","tuple",",","None","Feature","grid","defines","shape","of","the","output","neurons",".","The","new","shape","should","be","compatible","with","the","number","of","outputs",".","It","means","that","the","following","condition","should","be","true",":","..","code-block",":",":","python","np.prod","(","features_grid",")","==","n_outputs","SOFM","implementation","supports","n-dimensional","grids",".","For","instance",",","in","order","to","specify","grid","as","cube","instead","of","the","regular","rectangular","shape","we","can","set","up","options","as","the","following",":","..","code-block",":",":","python","SOFM","(","...","features_grid=","(","5",",","5",",","5",")",",","...",")","Defaults","to","``","(","n_outputs",",","1",")","``",".","grid_type",":","{","{","``","rect","``",",","``","hexagon","``","}","}","Defines","connection","type","in","feature","grid",".","Type","defines","which","neurons","we","will","consider","as","closest","to","the","winning","neuron","during","the","training",".","-","``","rect","``","-","Connections","between","neurons","will","be","organized","in","hexagonal","grid",".","-","``","hexagon","``","-","Connections","between","neurons","will","be","organized","in","hexagonal","grid",".","It","works","only","for","1d","or","2d","grids",".","Defaults","to","``","rect","``",".","distance",":","{","{","``","euclid","``",",","``","dot_product","``",",","``","cos","``","}","}","Defines","function","that","will","be","used","to","compute","closest","weight","to","the","input","sample",".","-","``","dot_product","``",":","Just","a","regular","dot","product","between","data","sample","and","network","'s","weights","-","``","euclid","``",":","Euclidean","distance","between","data","sample","and","network","'s","weights","-","``","cos","``",":","Cosine","distance","between","data","sample","and","network","'s","weights","Defaults","to","``","euclid","``",".","reduce_radius_after",":","int","or","None","Every","specified","number","of","epochs","``","learning_radius","``","parameter","will","be","reduced","by","``","1","``",".","Process","continues","until","``","learning_radius","``","equal","to","``","0","``",".","The","``","None","``","value","disables","parameter","reduction","during","the","training",".","Defaults","to","``","100","``",".","reduce_step_after",":","int","or","None","Defines","reduction","rate","at","which","parameter","``","step","``","will","be","reduced","using","the","following","formula",":","..","code-block",":",":","python","step","=","step","\/","(","1","+","current_epoch","\/","reduce_step_after",")","The","``","None","``","value","disables","parameter","reduction","during","the","training",".","Defaults","to","``","100","``",".","reduce_std_after",":","int","or","None","Defines","reduction","rate","at","which","parameter","``","std","``","will","be","reduced","using","the","following","formula",":","..","code-block",":",":","python","std","=","std","\/","(","1","+","current_epoch","\/","reduce_std_after",")","The","``","None","``","value","disables","parameter","reduction","during","the","training",".","Defaults","to","``","100","``",".","weight",":","array-like",",","Initializer","or","{","{","``","init_pca","``",",","``","sample_from_data","``","}","}","Neural","network","weights",".","Value","defined","manualy","should","have","shape","``","(","n_inputs",",","n_outputs",")","``",".","Also",",","it","'s","possible","to","initialized","weights","base","on","the","training","data",".","There","are","two","options",":","-","``","sample_from_data","``","-","Before","starting","the","training","will","randomly","take","number","of","training","samples","equal","to","number","of","expected","outputs",".","-","``","init_pca","``","-","Before","training","starts","SOFM","will","applies","PCA","on","a","covariance","matrix","build","from","the","training","samples",".","Weights","will","be","generated","based","on","the","two","eigenvectors","associated","with","the","largest","eigenvalues",".","Defaults","to",":","class",":","`","Normal","(",")","<","neupy.init.Normal",">","`",".","{","BaseNetwork.step","}","{","BaseNetwork.show_epoch","}","{","BaseNetwork.shuffle_data","}","{","BaseNetwork.signals","}","{","Verbose.verbose","}","Methods","--","--","--","-","init_weights","(","train_data",")","Initialized","weights","based","on","the","input","data",".","It","works","only","for","the","`","init_pca","`","and","`","sample_from_data","`","options",".","For","other","cases","it","will","throw","an","error",".","{","BaseSkeleton.predict","}","{","BaseAssociative.train","}","{","BaseSkeleton.fit","}","Examples","--","--","--","--",">",">",">","import","numpy","as","np",">",">",">","from","neupy","import","algorithms",",","utils",">",">",">",">",">",">","utils.reproducible","(",")",">",">",">",">",">",">","data","=","np.array","(","[","...","[","0.1961",",","0.9806","]",",","...","[","-0.1961",",","0.9806","]",",","...","[","-0.5812",",","-0.8137","]",",","...","[","-0.8137",",","-0.5812","]",",","...","]",")",">",">",">",">",">",">","sofm","=","algorithms.SOFM","(","...","n_inputs=2",",","...","n_outputs=2",",","...","step=0.1",",","...","learning_radius=0","...",")",">",">",">","sofm.train","(","data",",","epochs=100",")",">",">",">","sofm.predict","(","data",")","array","(","[","[","0",",","1","]",",","[","0",",","1","]",",","[","1",",","0","]",",","[","1",",","0","]","]",")"]
code: def predict_raw(self, X):
      X = format_data(X, is_feature1d=(self.n_inputs == 1))
  
      if X.ndim != 2:
          raise ValueError("Only 2D inputs are allowed")
  
      n_samples = X.shape[0]
      output = np.zeros((n_samples, self.n_outputs))
  
      for i, input_row in enumerate(X):
          output[i, :] = self.distance.func(
              input_row.reshape(1, -1), self.weight
          )
  
      return output
  
imports: from __future__ import division
  from collections import namedtuple
  import six
  import numpy
  from numpy.linalg import norm
  from neupy import init
  from neupy.utils import as_tuple, format_data
  from neupy.algorithms import Kohonen
  from neupy.exceptions import WeightInitializationError
  from neupy.algorithms.associative.base import BaseAssociative
  from neupy.core.properties import BaseProperty, TypedListProperty, ChoiceProperty, NumberProperty, ParameterProperty, IntProperty
  from .randomized_pca import randomized_pca
  from .neighbours import find_step_scaler_on_rect_grid, find_neighbours_on_rect_grid, find_neighbours_on_hexagon_grid, find_step_scaler_on_hexagon_grid
label_desc: Use image node_id 2 for calling the SOFM obj's underlying member method code with example usage: obj.predict_raw(X) and returns: output