Exemplo n.º 1
0
def _replace_relu(chain):
    for key, funcs in chain.functions.items():
        for i in range(len(funcs)):
            if hasattr(funcs[i], 'functions'):
                _replace_relu(funcs[i])
            elif funcs[i] is F.relu:
                funcs[i] = GuidedReLU()
Exemplo n.º 2
0
 def __init__(self, model, n_out):
     super(GuidedBackprop, self).__init__(copy.deepcopy(model), n_out)
     for key, funcs in self.model.base.functions.items():
         if (key != 'fc6' and key != 'prob'):
             for i in range(len(funcs)):
                 if funcs[i] is F.relu:
                     funcs[i] = GuidedReLU()
Exemplo n.º 3
0
 def __init__(self, model):
     super(GuidedBackprop, self).__init__(copy.deepcopy(model))
     for key, funcs in self.model.functions.items():
         for i in range(len(funcs)):
             if funcs[i] is F.relu:
                 funcs[i] = GuidedReLU()
             elif isinstance(funcs[i], chainer.Chain):
                 self._replace_relu(funcs[i])
Exemplo n.º 4
0
 def _replace_relu(self, chain):
     for child in chain.children():
         if hasattr(child, 'functions'):
             for key, funcs in child.functions.items():
                 for i in range(len(funcs)):
                     if funcs[i] is F.relu:
                         funcs[i] = GuidedReLU()
         elif isinstance(child, chainer.Chain):
             self._replace_relu(child)