コード例 #1
0
    def test_n_for_b(self):
        p_x_train, p_x_test, x_train, x_test, y_train, y_test, im, om = \
                                                        util.set_sample(1, 1, 100, 40)
        bc = b_classfy.b_classfy([im, 200, 150, om], isClassification=True)
        bc.pre_training(p_x_train, p_x_test)

        self.assertGreater(bc.learn(x_train, y_train, x_test, y_test), 0.8)
コード例 #2
0
ファイル: test_nn.py プロジェクト: fukatani/Chainer_training
    def test_n_for_b(self):
        p_x_train, p_x_test, x_train, x_test, y_train, y_test, im, om = \
                                                        util.set_sample(1, 1, 100, 40)
        bc = b_classfy.b_classfy([im, 200, 150, om], isClassification=True)
        bc.pre_training(p_x_train, p_x_test)

        self.assertGreater(bc.learn(x_train, y_train, x_test, y_test), 0.8)
コード例 #3
0
ファイル: test_nn.py プロジェクト: fukatani/Chainer_training
 def test_auto_encoder(self):
     p_x_train, p_x_test, x_train, x_test, y_train, y_test, im, om = \
                                                     util.set_sample(60, 1, 40, 20, split_mode='pp', offset_cancel=True, same_sample=10)
     bc = auto_encoder.Autoencoder([im, 200, 150, im], epoch=40, is_classification=False, nobias=False)
     bc.pre_training(p_x_train, p_x_test)
     bc.learn(x_train, x_train, x_test, x_test)
     #bc.disp_w()
     self.assertLess(bc.final_test(x_test[0:9], x_test[0:9], False), 0.1)
コード例 #4
0
 def test_auto_encoder(self):
     p_x_train, p_x_test, x_train, x_test, y_train, y_test, im, om = \
                                                     util.set_sample(60, 1, 40, 20, split_mode='pp', offset_cancel=True, same_sample=10)
     bc = auto_encoder.Autoencoder([im, 200, 150, im],
                                   epoch=40,
                                   is_classification=False,
                                   nobias=False)
     bc.pre_training(p_x_train, p_x_test)
     bc.learn(x_train, x_train, x_test, x_test)
     #bc.disp_w()
     self.assertLess(bc.final_test(x_test[0:9], x_test[0:9], False), 0.1)
コード例 #5
0
                 epoch=10,
                 **keywords):

        AbstractChain.__init__(self,
                               n_units=n_units,
                               is_classification=is_classification,
                               epoch=epoch,
                               batch_size=batch_size,
                               visualize=True,
                               **keywords)

        #configuration
        self.plot_enable = plot_enable
        self.save_as_png = save_as_png
        if save_as_png and not os.path.exists(util.IMAGE_DIR):
            os.mkdir(util.IMAGE_DIR)

        # Save final self.model
        if pickle_enable:
            pickle.dump(self.model, open('self.model', 'w'), -1)


if __name__ == '__main__':
    p_x_train, p_x_test, x_train, x_test, y_train, y_test, im, om = \
                                                    util.set_sample(1, 1, 100, 40)
    bc = b_classfy([im, 150, 150, om], isClassification=True)
    bc.pre_training(p_x_train, p_x_test)
    bc.learn(x_train, y_train, x_test, y_test)
    #bc.disp_w()
    bc.final_test(x_test[0:9], y_test[0:9])
コード例 #6
0
        if not isinstance(x_data, Variable):
            x_data = Variable(x_data)
        for i, model in enumerate(self):
            if i == len(self) - 1 and self.pre_trained:
                x_data = model(x_data)
            else:
                x_data = F.dropout(F.relu(model(x_data)), train=train)
        return x_data


if __name__ == '__main__':
    p_x_train0, p_x_test0, x_train0, x_test0, y_train0, y_test0, im, om = \
        util.set_sample(60, 1, 40, 20,
                        split_mode='pp',
                        #offset_cancel=True,
                        first_cancel=True,
                        #normal_constant=1709.0,
                        same_sample=70,
                        spec_target=0,
                        )
    p_x_train1, p_x_test1, x_train1, x_test1, y_train1, y_test1, im, om = \
        util.set_sample(60, 1, 40, 20,
                        split_mode='pp',
                        first_cancel=True,
                        div_reference=True,
                        #normal_constant=1709.0,
                        )

    bc = Autoencoder([im, 150, 120, im],
                     epoch=100,
                     is_classification=False,
                     nobias=True)