コード例 #1
0
ファイル: rbf_network.py プロジェクト: yuvarajan1212/aifh
    def __init__(self, input_count, rbf_count, output_count):
        """ Create an RBF network with the specified shape.
        @param input_count: The input count.
        @param rbf_count: The RBF function count.
        @param output_count:  The output count.
        """
        self.input_count = input_count
        self.output_count = output_count

        # calculate input and output weight counts
        # add 1 to output to account for an extra bias node
        input_weight_count = input_count * rbf_count
        output_weight_count = (rbf_count + 1) * output_count
        rbf_params = (input_count + 1) * rbf_count
        self.long_term_memory = np.zeros(
            (input_weight_count + output_weight_count + rbf_params),
            dtype=float)

        self.index_input_weights = 0
        self.index_output_weights = input_weight_count + rbf_params

        self.rbf = {}

        # default the Rbf's to gaussian
        for i in range(0, rbf_count):
            rbf_index = input_weight_count + ((input_count + 1) * i)
            self.rbf[i] = RbfGaussian(input_count, self.long_term_memory,
                                      rbf_index)
コード例 #2
0
 def test_gaussian(self):
     params = [5, 0, 0, 0]
     funct = RbfGaussian(3, params, 0);
     x = [-1, 0, 1]
     y = funct.evaluate(x);
     self.assertEquals(0.9607894391523232, y, 7)