neupy.algorithms.memory.cmac module
- class neupy.algorithms.memory.cmac.CMAC[source]
 Cerebellar Model Articulation Controller (CMAC) Network based on memory.
Parameters: - quantization : int
 Network transforms every input to discrete value. Quantization value controls number of total number of categories after quantization, defaults to 10.
- associative_unit_size : int
 Number of associative blocks in memory, defaults to 2.
- 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.
Notes
- Network always use Mean Absolute Error (MAE).
 - Network works for multi dimensional target values.
 
Examples
>>> import numpy as np >>> from neupy.algorithms import CMAC >>> >>> train_space = np.linspace(0, 2 * np.pi, 100) >>> test_space = np.linspace(np.pi, 2 * np.pi, 50) >>> >>> X_train = np.reshape(train_space, (100, 1)) >>> X_test = np.reshape(test_space, (50, 1)) >>> >>> y_train = np.sin(X_train) >>> y_test = np.sin(X_test) >>> >>> cmac = CMAC( ... quantization=100, ... associative_unit_size=32, ... step=0.2, ... ) ... >>> cmac.train(X_train, y_train, epochs=100) >>> >>> predicted_test = cmac.predict(X_test) >>> cmac.score(y_test, predicted_test) 0.0023639417543036569
Attributes: - weight : dict
 Network’s weight that contains memorized patterns.
Methods
predict(X) Predicts output for the specified input. train(X_train, y_train, X_test=None, y_test=None, epochs=100) Trains the network to the data X. Network trains until maximum number of epochs was reached. fit(*args, **kwargs) Alias to the train method. - associative_unit_size = None[source]
 
- get_memory_coords(quantized_value)[source]
 
- get_result_by_coords(coords)[source]
 
- 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 = {'associative_unit_size': Option(class_name='CMAC', value=IntProperty(name="associative_unit_size")), 'quantization': Option(class_name='CMAC', value=IntProperty(name="quantization")), '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"))}[source]
 
- predict(X)[source]
 
- quantization = None[source]
 
- quantize(X)[source]
 
- score(X, y)[source]
 
- train(X_train, y_train, X_test=None, y_test=None, epochs=100)[source]
 Method train neural network.
Parameters: - X_train : array-like
 - y_train : array-like or None
 - X_test : array-like or None
 - y_test : array-like or None
 - epochs : int
 Defaults to 100.
- epsilon : float or None
 Defaults to None.