예제 #1
0
    def test_reset_compute(self):
        network = RbfNetwork(2, 1, 1)
        total = 0

        for i in xrange(0, len(network.long_term_memory)):
            total += network.long_term_memory[i]

        self.assertEquals(0, total)

        network.reset()

        total = 0
        for i in xrange(0, len(network.long_term_memory)):
            total += network.long_term_memory[i]

        self.assertTrue(total > 1)
예제 #2
0
    def test_reset_compute(self):
        network = RbfNetwork(2, 1, 1)
        total = 0

        for i in xrange(0, len(network.long_term_memory)):
            total += network.long_term_memory[i]

        self.assertEquals(0, total)

        network.reset()

        total = 0
        for i in xrange(0, len(network.long_term_memory)):
            total += network.long_term_memory[i]

        self.assertTrue(total > 1)
예제 #3
0
# Normalize iris species using one-of-n.
# We could have used equilateral as well.  For an example of equilateral, see the example_nm_iris example.
norm.norm_col_one_of_n(iris_work, 4, classes, 0, 1)

# Prepare training data.  Separate into input and ideal.
training = np.array(iris_work)
training_input = training[:, 0:4]
training_ideal = training[:, 4:7]

# Create an RBF network.  There are four inputs and two outputs.
# There are also five RBF functions used internally.
# You can experiment with different numbers of internal RBF functions.
# However, the input and output must match the data set.
network = RbfNetwork(4, 4, 3)
network.reset()


def score_funct(x):
    """
    The score function for Iris anneal.
    @param x:
    @return:
    """
    global best_score
    global input_data
    global output_data
    # Update the network's long term memory to the vector we need to score.
    network.copy_memory(x)
    # Loop over the training set and calculate the output for each.
    actual_output = []
예제 #4
0
# Normalize iris species using one-of-n.
# We could have used equilateral as well.  For an example of equilateral, see the example_nm_iris example.
norm.norm_col_one_of_n(iris_work, 4, classes, 0, 1)


# Prepare training data.  Separate into input and ideal.
training = np.array(iris_work)
training_input = training[:, 0:4]
training_ideal = training[:, 4:7]

# Create an RBF network.  There are four inputs and two outputs.
# There are also five RBF functions used internally.
# You can experiment with different numbers of internal RBF functions.
# However, the input and output must match the data set.
network = RbfNetwork(4, 4, 3)
network.reset()

def score_funct(x):
    """
    The score function for Iris anneal.
    @param x:
    @return:
    """
    global best_score
    global input_data
    global output_data
    # Update the network's long term memory to the vector we need to score.
    network.copy_memory(x)
    # Loop over the training set and calculate the output for each.
    actual_output = []
    for input_data in training_input: