示例#1
0
 def predict_extended(self, inputs):
     """
     Predicts targets for given data set.
     @param data_set: data Set inheriting AbstractDataSet
     :return: List of predictions, i.e. output of this net for each
     observation in the data set.
     """
     data_set = NumericalDataSet(inputs)
     predictions = []
     # loop through dataset
     for observation, _ in data_set.gen_observations():
         # make sure it is a numpy array
         input_arr = np.array(observation)
         outputs = self.feedforward(input_arr)
         predictions.append(outputs[-1])
     return predictions
示例#2
0
 def predict_extended(self, inputs):
     """
     Predicts targets for given data set.
     @param data_set: data Set inheriting AbstractDataSet
     :return: List of predictions, i.e. output of this net for each
     observation in the data set.
     """
     data_set = NumericalDataSet(inputs)
     predictions = []
     # loop through dataset
     for observation, _ in data_set.gen_observations( ):
         # make sure it is a numpy array
         input_arr = np.array(observation)
         outputs = self.feedforward(input_arr)
         predictions.append(outputs[-1])
     return predictions
示例#3
0
    def test_gen_observations(self):
        '''
        Test generator getting all observations as (1,x) numpy array from input dataset
        '''
        inputs = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2], [3, 3, 3],
                           [4, 4, 4]])
        labels = np.array([[0], [1], [2], [3], [4]])
        dataSet = NumericalDataSet(inputs, labels)

        i = 0
        for inputs, labels in dataSet.gen_observations():
            assert_equal(inputs, i * np.ones((1, 3)),
                         'wrong input at observation %d' % i)
            assert_equal(labels, i * np.ones((1, 1)),
                         'wrong label at observation %d' % i)
            i = i + 1