1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| C = ttrain.max() + 1 H1 = 16 H2 = 32 H3 = 64
NN = Chain(cnn1 = L.Convolution2D(ch,H1,ksize=1,stride=1,pad=0), cnn2 = L.Convolution2D(H1,H1,ksize=3,stride=1,pad=0), cnn3 = L.Convolution2D(H1,H1,ksize=5,stride=1,pad=0), cnn4 = L.Convolution2D(H1,H2,ksize=1,stride=1,pad=0), cnn5 = L.Convolution2D(H2,H2,ksize=3,stride=1,pad=0), cnn6 = L.Convolution2D(H2,H2,ksize=5,stride=1,pad=0), cnn7 = L.Convolution2D(H2,H3,ksize=1,stride=1,pad=0), cnn8 = L.Convolution2D(H3,H3,ksize=3,stride=1,pad=0), cnn9 = L.Convolution2D(H3,C,ksize=5,stride=1,pad=3), bnorm1 = L.BatchNormalization(H1), bnorm2 = L.BatchNormalization(H1), bnorm3 = L.BatchNormalization(H1), bnorm4 = L.BatchNormalization(H2), bnorm5 = L.BatchNormalization(H2), bnorm6 = L.BatchNormalization(H2), bnorm7 = L.BatchNormalization(H3), bnorm8 = L.BatchNormalization(H3))
def model(x): h = NN.cnn1(x) h = F.relu(h) h = NN.bnorm1(h) h = NN.cnn2(h) h = F.relu(h) h = NN.bnorm2(h) h = NN.cnn3(h) h = F.relu(h) h = NN.bnorm3(h) h = F.max_pooling_2d(h, 2) h = NN.cnn4(h) h = F.relu(h) h = NN.bnorm4(h) h = NN.cnn5(h) h = F.relu(h) h = NN.bnorm5(h) h = NN.cnn6(h) h = F.relu(h) h = NN.bnorm6(h) h = F.max_pooling_2d(h, 2) h = NN.cnn7(h) h = F.relu(h) h = NN.bnorm7(h) h = NN.cnn8(h) h = F.relu(h) h = NN.bnorm8(h) h = NN.cnn9(h) y = F.mean(h,axis=(2,3)) return y
|