Esempio n. 1
0
 def test_transform(self):
     testing_object = neurone.Neurone(
         b=3, bias=2, weights=[-5, 17, -4.67, 9, 0, -27, -13, 11, 99.2, 37])
     transformation = testing_object.transform_to_object()
     del testing_object
     testing_object_new = neurone.Neurone()
     testing_object_new.transform_from_object(transformation)
     del transformation
     self.assertEqual(testing_object_new.get_size(), 10)
     self.assertEqual(testing_object_new.get_weights_size(), 10)
     self.assertEqual(testing_object_new.get_bias(), 2)
     self.assertEqual(testing_object_new.get_b(), 3)
     self.assertEqual(testing_object_new.get_weights(),
                      [-5, 17, -4.67, 9, 0, -27, -13, 11, 99.2, 37])
Esempio n. 2
0
 def test_get_output2(self):
     testing_object = neurone.Neurone(
         b=2, bias=2, weights=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
     self.assertEqual(
         testing_object.get_output([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),
         0.9820137900379085)
     """Trzy pierwsze testy back propagation sprawdzają czy ustawianie teaching_ratio i teaching_variable daje odpowiednie efekty"""
Esempio n. 3
0
 def random_generate(self):
     if (self.__size_of_input is None or self.__count_of_neurons is None
             or len(self.__array_of_neurons) != 0):
         raise Exception("Hidden Layer is actualy generate")
     for i in range(self.__count_of_neurons):
         new_neurone = Neurone.Neurone(size=self.__size_of_input,
                                       teaching=True)
         new_neurone.random_generate()
         self.__array_of_neurons.append(new_neurone)
Esempio n. 4
0
 def test_sets(self):
     testing_object = neurone.Neurone(
         b=3, bias=2, weights=[-5, 17, -4.67, 9, 0, -27, -13, 11, 99.2, 37])
     self.assertEqual(testing_object.get_b(), 3)
     self.assertEqual(testing_object.get_bias(), 2)
     self.assertEqual(testing_object.get_weights(),
                      [-5, 17, -4.67, 9, 0, -27, -13, 11, 99.2, 37])
     testing_object.set_weight(4, 17)
     self.assertEqual(testing_object.get_weights(),
                      [-5, 17, -4.67, 9, 17, -27, -13, 11, 99.2, 37])
Esempio n. 5
0
 def transform_from_object(self, obj):
     if len(self.__array_of_neurons) != 0:
         raise Exception("You cannot create")
     self.__count_of_neurons = obj['countOfNeurons']
     self.__size_of_input = obj['sizeOfInput']
     self.__array_of_neurons = []
     for i in obj['arrayOfNeurons']:
         new_neurone = Neurone.Neurone()
         new_neurone.transform_from_object(i)
         self.__array_of_neurons.append(new_neurone)
Esempio n. 6
0
 def test_back_propagation5(self):
     testing_object = neurone.Neurone(
         b=2, bias=2, weights=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
     self.assertEqual(
         testing_object.get_output(
             [1, 2, 7, 0, 19, 7.5, 4.32, 9, 181, -1083]),
         0.9820137900379085)
     testing_object.back_propagation(77, 0)
     self.assertEqual(
         testing_object.get_output(
             [1, 2, 7, 0, 19, 7.5, 4.32, 9, 181, -1083]),
         0.9820137900379085)
Esempio n. 7
0
 def test_get_output(self):
     testing_object = neurone.Neurone(b=2,
                                      bias=2,
                                      weights=[1, 2, 3, 4, 5, 6])
     self.assertEqual(testing_object.get_output([6, 7, 4, 19, 7, 1]), 1.0)