@@ -0,0 +1,1757 @@
+package com.guokr.dbn;%0A%0Aimport mikera.vectorz.AVector;%0Aimport mikera.vectorz.Vectorz;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport com.guokr.dbn.DBN;%0A%0Apublic class DBNTest %7B%0A%0A    @Test%0A    public void test() %7B%0A%0A        int%5B%5D sizes_per_layer = %7B 6, 3, 3, 2 %7D;%0A        DBN dbn = new DBN(sizes_per_layer);%0A%0A        // pretrain%0A%0A        int k = 1;%0A        double pretrain_lr = 0.1 / 6;%0A        int pretraining_epochs = 1000;%0A%0A        double%5B%5D%5B%5D traindata = %7B %7B 1, 1, 1, 0, 0, 0 %7D, %7B 1, 0, 1, 0, 0, 0 %7D, %7B 1, 1, 1, 0, 0, 0 %7D,%0A                %7B 0, 0, 1, 1, 1, 0 %7D, %7B 0, 0, 1, 1, 0, 0 %7D, %7B 0, 0, 1, 1, 1, 0 %7D %7D;%0A%0A        for (int i = 0; i %3C pretraining_epochs; i++) %7B%0A            for (double%5B%5D item : traindata) %7B%0A                dbn.pretrain(k, pretrain_lr, Vectorz.create(item));%0A            %7D%0A        %7D%0A%0A        // finetune%0A%0A        double finetune_lr = 0.1;%0A        int finetune_epochs = 500;%0A%0A        double%5B%5D%5B%5D tunedata = %7B %7B 1, 0 %7D, %7B 1, 0 %7D, %7B 1, 0 %7D, %7B 0, 1 %7D, %7B 0, 1 %7D, %7B 0, 1 %7D, %7D;%0A%0A        for (int i = 0; i %3C finetune_epochs; i++) %7B%0A            for (int j = 0; j %3C 6; j++) %7B%0A                dbn.finetune(finetune_lr, Vectorz.create(traindata%5Bj%5D), Vectorz.create(tunedata%5Bj%5D));%0A            %7D%0A        %7D%0A%0A        // test%0A%0A        double%5B%5D%5B%5D testdata = %7B %7B 1, 1, 0, 0, 0, 0 %7D, %7B 1, 1, 1, 1, 0, 0 %7D, %7B 0, 0, 0, 1, 1, 0 %7D, %7B 0, 0, 1, 1, 1, 0 %7D, %7D;%0A        double%5B%5D%5B%5D results = %7B %7B 1, 0 %7D, %7B 1, 0 %7D, %7B 0, 1 %7D, %7B 0, 1 %7D, %7D;%0A%0A        for (int i = 0; i %3C 4; i++) %7B%0A            AVector result = dbn.predict(Vectorz.create(testdata%5Bi%5D));%0A            System.out.println(result);%0A            AVector test = Vectorz.create(results%5Bi%5D);%0A            Assert.assertTrue(%22error is greater than expected!%22, test.epsilonEquals(result, 0.3));%0A        %7D%0A    %7D%0A%0A%7D%0A

add test