def test_test_rand_weight(self):

        constraint = 1.0
        sample = [rand_weight() for i in range(1000)]
        self.assertGreaterEqual(constraint, max(sample))
        self.assertLessEqual(-constraint, min(sample))

        constraint = 0.5
        sample = [rand_weight(constraint) for i in range(1000)]
        self.assertGreaterEqual(constraint, max(sample))
        self.assertLessEqual(-constraint, min(sample))
    def test_test_rand_weight(self):

        constraint = 1.0
        sample = [rand_weight() for i in range(1000)]
        self.assertGreaterEqual(constraint, max(sample))
        self.assertLessEqual(-constraint, min(sample))

        constraint = 0.5
        sample = [rand_weight(constraint) for i in range(1000)]
        self.assertGreaterEqual(constraint, max(sample))
        self.assertLessEqual(-constraint, min(sample))
Exemple #3
0
    def randomize(self, random_constraint=RANDOM_CONSTRAINT):
        """
        This function assigns a random value to the input connections.
        The random constraint limits the scope of random variables.

        """

        for conn in self.input_connections:
            conn.set_weight(rand_weight(random_constraint))
    def randomize(self, random_constraint=RANDOM_CONSTRAINT):
        """
        This function assigns a random value to the input connections.
        The random constraint limits the scope of random variables.

        """

        for conn in self.input_connections:
            conn.set_weight(rand_weight(random_constraint))