Esempio n. 1
0
    def test_irpropplus(self):
        options = dict(minstep=0.001,
                       maxstep=1,
                       increase_factor=1.1,
                       decrease_factor=0.1,
                       step=1,
                       verbose=False)

        uniform = init.Uniform()
        params1 = dict(
            weight=uniform.sample((3, 10), return_array=True),
            bias=uniform.sample((10, ), return_array=True),
        )
        params2 = dict(
            weight=uniform.sample((10, 2), return_array=True),
            bias=uniform.sample((2, ), return_array=True),
        )

        network = layers.join(
            Input(3),
            Sigmoid(10, **params1),
            Sigmoid(2, **params2),
        )

        nw = algorithms.IRPROPPlus(copy.deepcopy(network), **options)
        nw.train(simple_x_train, simple_y_train, epochs=100)
        irprop_plus_error = nw.errors.train[-1]
        self.assertGreater(1e-4, nw.errors.train[-1])

        nw = algorithms.RPROP(copy.deepcopy(network), **options)
        nw.train(simple_x_train, simple_y_train, epochs=100)
        rprop_error = nw.errors.train[-1]
        self.assertGreater(rprop_error, irprop_plus_error)
Esempio n. 2
0
    def test_irpropplus(self):
        options = dict(minimum_step=0.001,
                       maximum_step=1,
                       increase_factor=1.1,
                       decrease_factor=0.1,
                       step=1,
                       verbose=False)
        nw = algorithms.IRPROPPlus(copy.deepcopy(self.connection), **options)

        nw.train(simple_input_train, simple_target_train, epochs=100)
        irprop_plus_error = nw.last_error_in()
        self.assertGreater(1e-4, nw.last_error_in())

        nw = algorithms.RPROP(copy.deepcopy(self.connection), **options)

        nw.train(simple_input_train, simple_target_train, epochs=100)
        rprop_error = nw.last_error_in()
        self.assertGreater(rprop_error, irprop_plus_error)
Esempio n. 3
0
	def select_algorithm(self, algorithm, options=None):
		try:
			self.network = algorithms.LevenbergMarquardt(self.layers)
			opt = options
			print(opt[1])
			print("Wybrano optymalizator: " + str(algorithm))
		except RecursionError:
			print("Problem rekursji")
			return None

		if algorithm == 'GradientDescent':
			self.network = algorithms.GradientDescent(self.layers)
		if algorithm == 'LevenbergMarquardt':
			self.network = algorithms.LevenbergMarquardt(connection=self.layers, mu=opt[0], mu_update_factor=opt[1])
		if algorithm == 'Adam':
			self.network = algorithms.Adam(self.layers)
		if algorithm == 'QuasiNewton':
			self.network = algorithms.QuasiNewton(self.layers)
		if algorithm == 'Quickprop':
			self.network = algorithms.Quickprop(self.layers)
		if algorithm == 'MinibatchGradientDescent':
			self.network = algorithms.MinibatchGradientDescent(self.layers)
		if algorithm == 'ConjugateGradient':
			self.network = algorithms.ConjugateGradient(self.layers)
		if algorithm == 'Hessian':
			self.network = algorithms.Hessian(self.layers)
		if algorithm == 'HessianDiagonal':
			self.network = algorithms.HessianDiagonal(self.layers)
		if algorithm == 'Momentum':
			self.network = algorithms.Momentum(self.layers)
		if algorithm == 'RPROP':
			self.network = algorithms.RPROP(self.layers)
		if algorithm == 'IRPROPPlus':
			self.network = algorithms.IRPROPPlus(self.layers)
		if algorithm == 'Adadelta':
			self.network = algorithms.Adadelta(self.layers)
		if algorithm == 'Adagrad':
			self.network = algorithms.Adagrad(self.layers)
		if algorithm == 'RMSProp':
			self.network = algorithms.RMSProp(self.layers)
		if algorithm == 'Adamax':
			self.network = algorithms.Adamax(self.layers)
Esempio n. 4
0
    def test_irpropplus(self):
        options = dict(minstep=0.001,
                       maxstep=1,
                       increase_factor=1.1,
                       decrease_factor=0.1,
                       step=1,
                       verbose=False)
        connection = [
            Input(3),
            Sigmoid(10, init_method='bounded', bounds=(0, 1)),
            Sigmoid(2, init_method='bounded', bounds=(0, 1)),
        ]

        nw = algorithms.IRPROPPlus(copy.deepcopy(connection), **options)
        nw.train(simple_input_train, simple_target_train, epochs=100)
        irprop_plus_error = nw.errors.last()
        self.assertGreater(1e-4, nw.errors.last())

        nw = algorithms.RPROP(copy.deepcopy(connection), **options)
        nw.train(simple_input_train, simple_target_train, epochs=100)
        rprop_error = nw.errors.last()
        self.assertGreater(rprop_error, irprop_plus_error)