예제 #1
0
    def classify(self, single_input_as_list):
        cur_input = single_input_as_list
        # Make the input layer
        cur_input_layer = Layer(len(cur_input), 0)
        cur_input_layer.from_input_list(cur_input)

        # Do forward propagation.
        # Returns a list of floats
        cur_model_output = self.forward_prop(cur_input_layer)

        # Find the index in the output that has the highest value
        val, idx = max(
            (val, idx) for (idx, val) in enumerate(cur_model_output))

        return idx
예제 #2
0
    def train(self, example_inputs, example_outputs):
        for cur_input, cur_desired_output in zip(example_inputs,
                                                 example_outputs):
            # Make the input layer
            cur_input_layer = Layer(len(cur_input), 0)
            cur_input_layer.from_input_list(cur_input)

            # Do forward propagation.
            # Returns a list of floats
            cur_model_output = self.forward_prop(cur_input_layer)

            cur_cost_function_result = self.back_prop(cur_input_layer,
                                                      cur_model_output,
                                                      cur_desired_output)

        return cur_cost_function_result