What's the input matrix for Stack Denoising Encoder function?

88 views Asked by At

I'm trying to use this example for training text data, which labeled as positive or negative. But I don't understand what input should be the input for train function. In test_sda function, it have some matrix like: train_X, train_Y, test_X, test_Y and some variable: train_N, test_N. I don't know what these mean.

In my case, I use SDA to build a Vietnamese Sentiment Classification, please guide me what data I should input for SDA.

private static void test_sda() {
    Random rng = new Random(123);

    double pretrain_lr = 0.1;
    double corruption_level = 0.3;
    int pretraining_epochs = 1000;
    double finetune_lr = 0.1;
    int finetune_epochs = 500;

    int train_N = 10;
    int test_N = 4;
    int n_ins = 28;
    int n_outs = 2;
    int[] hidden_layer_sizes = {15, 15};
    int n_layers = hidden_layer_sizes.length;

    // training data
    int[][] train_X = {
            {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1}
    };

    int[][] train_Y = {
            {1, 0},
            {1, 0},
            {1, 0},
            {1, 0},
            {1, 0},
            {0, 1},
            {0, 1},
            {0, 1},
            {0, 1},
            {0, 1}
    };

    // construct SdA
    SdA sda = new SdA(train_N, n_ins, hidden_layer_sizes, n_outs, n_layers, rng);

    // pretrain
    sda.pretrain(train_X, pretrain_lr, corruption_level, pretraining_epochs);

    // finetune
    sda.finetune(train_X, train_Y, finetune_lr, finetune_epochs);


    // test data
    int[][] test_X = {
            {1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1}
    };

    double[][] test_Y = new double[test_N][n_outs];

    // test
    for(int i=0; i<test_N; i++) {
        sda.predict(test_X[i], test_Y[i]);
        for(int j=0; j<n_outs; j++) {
            System.out.print(test_Y[i][j] + " ");
        }
        System.out.println();
    }
}

Many thanks.

0

There are 0 answers