neupy.algorithms.LinearSearch

class neupy.algorithms.LinearSearch[source]

Linear search is a step selection algorithm.

Parameters:
tol : float

Tolerance for termination, default to 0.1. Can be any number greater that 0.

maxiter : int

Maximum number of interations. Works only for the brent method. Defaults to 10.

search_method : {gloden, brent}

Linear search method. Can be golden for golden search or brent for Brent’s search, default to golden.

Warns:
It works only with algorithms based on backpropagation.

Examples

>>> from sklearn import datasets, preprocessing
>>> from sklearn.model_selection import train_test_split
>>> from neupy import algorithms, layers, estimators, environment
>>>
>>> environment.reproducible()
>>>
>>> dataset = datasets.load_boston()
>>> data, target = dataset.data, dataset.target
>>>
>>> data_scaler = preprocessing.MinMaxScaler()
>>> target_scaler = preprocessing.MinMaxScaler()
>>>
>>> x_train, x_test, y_train, y_test = train_test_split(
...     data_scaler.fit_transform(data),
...     target_scaler.fit_transform(target),
...     test_size=0.15
... )
>>>
>>> cgnet = algorithms.ConjugateGradient(
...     connection=[
...         layers.Input(13),
...         layers.Sigmoid(50),
...         layers.Sigmoid(1),
...     ],
...     search_method='golden',
...     addons=[algorithms.LinearSearch],
...     verbose=False
... )
>>>
>>> cgnet.train(x_train, y_train, epochs=100)
>>> y_predict = cgnet.predict(x_test).round(1)
>>>
>>> real = target_scaler.inverse_transform(y_test)
>>> predicted = target_scaler.inverse_transform(y_predict)
>>>
>>> error = estimators.rmsle(real, predicted)
>>> error
0.20752676697596578
maxiter = None[source]
options = {'maxiter': Option(class_name='LinearSearch', value=BoundedProperty(name="maxiter")), 'search_method': Option(class_name='LinearSearch', value=ChoiceProperty(name="search_method")), 'tol': Option(class_name='LinearSearch', value=BoundedProperty(name="tol"))}[source]
search_method = None[source]
tol = None[source]
train_epoch(input_train, target_train)[source]