def test_compare_bp_and_rprop(self): compare_networks( # Test classes partial(algorithms.GradientDescent, batch_size=None), partial(algorithms.RPROP, maxstep=0.1), # Test data (simple_x_train, simple_y_train), # Network configurations network=self.network, step=0.1, shuffle_data=True, verbose=False, # Test configurations epochs=50, show_comparison_plot=False)
def test_compare_bp_and_hessian(self): x_train, x_test, y_train, y_test = simple_classification() compare_networks( # Test classes partial(algorithms.GradientDescent, batch_size=None), partial(algorithms.Hessian, penalty_const=1), # Test data (x_train, y_train, x_test, y_test), # Network configurations network=[layers.Input(10), layers.Sigmoid(15), layers.Sigmoid(1)], shuffle_data=True, verbose=False, show_epoch=1, # Test configurations epochs=5, show_comparison_plot=False)
def test_compare_lvq_and_lvq21(self): dataset = datasets.load_iris() data, target = dataset.data, dataset.target # Prepare the same weights for the fair comparison lvq = algorithms.LVQ(n_inputs=4, n_subclasses=3, n_classes=3) lvq.train(data, target, epochs=1) prepared_lvq_weights = lvq.weight compare_networks( algorithms.LVQ, partial(algorithms.LVQ21, epsilon=0.1), data=[data, target], epochs=10, show_comparison_plot=False, n_inputs=4, n_subclasses=3, n_classes=3, weight=prepared_lvq_weights, )
def test_compare_lvq_and_lvq3(self): dataset = datasets.load_iris() data, target = dataset.data, dataset.target # Prepare the same weights for the fair comparison lvq = algorithms.LVQ(n_inputs=4, n_subclasses=6, n_classes=3) lvq.train(data, target, epochs=1) prepared_lvq_weights = lvq.weight compare_networks( algorithms.LVQ, partial(algorithms.LVQ3, epsilon=0.4), data=[data, target], epochs=100, show_comparison_plot=False, n_inputs=4, n_subclasses=6, n_classes=3, prototypes_per_class=[4, 1, 1], step=0.001, weight=prepared_lvq_weights, )
def test_momentum_with_minibatch(self): x_train, _, y_train, _ = simple_classification() compare_networks( # Test classes partial(algorithms.Momentum, batch_size=None), partial(algorithms.Momentum, batch_size=1), # Test data (x_train, y_train), # Network configurations network=[ layers.Input(10), layers.Sigmoid(20), layers.Sigmoid(1) ], step=0.25, momentum=0.1, shuffle_data=True, verbose=False, # Test configurations epochs=40, show_comparison_plot=False, )
def test_compare_bp_and_hessian(self): x_train, _, y_train, _ = simple_classification() params = dict(weight=init.Uniform(-0.1, 0.1), bias=init.Uniform(-0.1, 0.1)) compare_networks( # Test classes partial(algorithms.GradientDescent, batch_size=None), partial(algorithms.HessianDiagonal, min_eigval=0.1), # Test data (x_train, y_train), # Network configurations network=[ layers.Input(10), layers.Sigmoid(20, **params), layers.Sigmoid(1, **params), ], step=0.1, shuffle_data=True, verbose=False, # Test configurations epochs=50, show_comparison_plot=False)
def test_compare_bp_and_cg(self): x_train, x_test, y_train, y_test = simple_classification() compare_networks( # Test classes partial( partial(algorithms.GradientDescent, batch_size=None), step=1.0, ), partial(algorithms.ConjugateGradient, update_function='fletcher_reeves'), # Test data (asfloat(x_train), asfloat(y_train)), # Network configurations network=layers.join( layers.Input(10), layers.Sigmoid(5), layers.Sigmoid(1), ), loss='mse', shuffle_data=True, # Test configurations epochs=50, show_comparison_plot=False)