支持double类型的输入。
原代码是int数据,不太适用,还是double类型好。牵一发而动全身,我已经将double类可运行代码改好。
入口也比较简单:- public static void main(String[] args) {
- double[][] train_X = { { 1, 1, 1, 0, 0, 0 }, { 1, 0, 1, 0, 0, 0 },
- { 1, 1, 1, 0, 0, 0 }, { 0, 0, 1, 1, 1, 0 },
- { 0, 0, 1, 1, 0, 0 }, { 0, 0, 1, 1, 1, 0 } };
- double[][] train_Y = { { 1, 0 }, { 1, 0 }, { 1, 0 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, };
- // test data
- double[][] test_X = { { 1, 1, 0, 0, 0, 0 }, { 1, 1, 1, 1, 0, 0 },
- { 0, 0, 0, 1, 1, 0 }, { 0, 0, 1, 1, 1, 0 }, };
- double[][] test_Y = new double[4][2];
- test_dbn(train_X, train_Y, test_X, test_Y);
- // test
- for (int i = 0; i < 4; i++) {
- for (int j = 0; j < 2; j++) {
- System.out.print(test_Y[i][j] + " ");
- }
- System.out.println();
- }
- }
复制代码
|