Ejemplo n.º 1
0
    def test_forward_propagation(self):
        """

        check if the matrix multiplications in forward propagationin are
        working properly.

        """
        training_dataset   = DataSet(os.path.join(combivep_settings.COMBIVEP_CENTRAL_TEST_DATASET_DIR,
                                                                   'dummy_training_dataset'))
        mlp = Mlp(training_dataset.n_features, seed=20)
        out = mlp.forward_propagation(training_dataset)
        self.assertEqual(round(out[0][0], 4), 0.5022, msg='forward propagation does not functional properly')
Ejemplo n.º 2
0
    def test_fix_random_weight(self):
        """

        check if the initial random values of weight matrixes are likely to be
        random.

        """
        training_dataset   = DataSet(os.path.join(combivep_settings.COMBIVEP_CENTRAL_TEST_DATASET_DIR,
                                                                   'dummy_training_dataset'))
        mlp = Mlp(training_dataset.n_features, seed=20)
        self.assertEqual(round(mlp.get_weights1()[0][1], 4), 0.0090, msg='MLP is not ready for test because the random value is not fix')
        self.assertEqual(round(mlp.get_weights1()[0][0], 4), 0.0059, msg='MLP is not ready for test because the random value is not fix')
Ejemplo n.º 3
0
    def __init__(self, training_dataset,
                       validation_dataset,
                       seed=combivep_settings.DEFAULT_SEED, 
                       n_hidden_nodes=combivep_settings.DEFAULT_HIDDEN_NODES, 
                       figure_dir=combivep_settings.DEFAULT_FIGURE_DIR):
        Mlp.__init__(self, training_dataset.n_features,
                                        seed=seed,
                                        n_hidden_nodes=n_hidden_nodes)

        self.__training_dataset   = training_dataset
        self.__validation_dataset = validation_dataset
        self.__n_hidden_nodes     = n_hidden_nodes
        self.__figure_dir         = figure_dir
Ejemplo n.º 4
0
    def test_forward_propagation(self):
        """

        check if the matrix multiplications in forward propagationin are
        working properly.

        """
        training_data = DataSet(os.path.join(cbv_const.CBV_SAMPLE_DATASET_DIR,
                                             'dummy_training_dataset'))
        mlp = Mlp(training_data.n_features, seed=20)
        out = mlp.forward_propagation(training_data)
        self.assertEqual(round(out[0][0], 4),
                         0.5022,
                         msg="forward propagation doesn't function properly")
Ejemplo n.º 5
0
    def test_one_round_forward_backward_weight_update(self):
        """

        to see if can correctly run one round of "forward", "backward" and
        "weight update"

        """
        training_dataset   = DataSet(os.path.join(combivep_settings.COMBIVEP_CENTRAL_TEST_DATASET_DIR,
                                                                   'dummy_training_dataset'))
        mlp = Mlp(training_dataset.n_features, seed=20)
        mlp.forward_propagation(training_dataset)
        mlp.backward_propagation(training_dataset)
        weights1, weights2 = mlp.weight_update(training_dataset)
        self.assertEqual(round(weights1[0][0], 4), 0.0059, msg='one round of forward propagation, backward propagation and weight update, does not functional properly')
Ejemplo n.º 6
0
    def test_one_round_forward_backward_weight_update(self):
        """

        to see if can correctly run one round of "forward", "backward" and
        "weight update"

        """
        training_data = DataSet(os.path.join(cbv_const.CBV_SAMPLE_DATASET_DIR,
                                             'dummy_training_dataset'))
        mlp = Mlp(training_data.n_features, seed=20)
        mlp.forward_propagation(training_data)
        mlp.backward_propagation(training_data)
        weights1, weights2 = mlp.weight_update(training_data)
        self.assertEqual(round(weights1[0][0], 4),
                         0.0059,
                         msg='one round of forward propagation, backward propagation and weight update, does not function properly')