## module import
import chainer
import chainer.functions as F
import chainer.links as L
from chainer import training, Reporter, report, report_scope
from chainer.training import extensions
from numpy import *
from scipy import *
import numpy as np
from chainer import datasets
## define networks
class MYNN(chainer.Chain):
def __init__(self):
super(MYNN,self).__init__()
with self.init_scope():
self.bn0 = L.BatchNormalization(784)
self.h0 = L.Highway(784)
self.l1 = L.Linear(100)
self.h1 = L.Highway(100)
self.bn1 = L.BatchNormalization(100)
self.bn2 = L.BatchNormalization(100)
self.l2 = L.Linear(10)
self.bn3 = L.BatchNormalization(10)
def __call__(self,x):
h = self.bn0(x)
h = self.h0(h)
h = F.dropout(h, ratio=0.2)
h = F.relu(self.bn1(self.l1(h)))
h = F.dropout(h, ratio=0.2)
h = self.h1(h)
h = self.bn2(h)
h = F.dropout(h, ratio=0.2)
h = self.bn3(self.l2(h))
return h
class Classifier(chainer.Chain):
def __init__(self, predictor):
super(Classifier, self).__init__()
with self.init_scope():
self.predictor = predictor