Exemple #1
0
 def inner(model):
     layer_t = model(layer)
     layer_t = _extract_act_pos(layer_t, x, y)
     if weight is None:
         return -layer_t.mean()
     else:
         return -(layer_t.squeeze() * weight).mean()
Exemple #2
0
 def inner(model):
     layer_t = model(layer)
     layer_t = _extract_act_pos(layer_t, x, y)
     return -layer_t[:, n_channel].mean()
Exemple #3
0
 def inner(model):
     # breakpoint()
     layer_t = model(layer)
     layer_t = _extract_act_pos(layer_t, x, y)
     return -torch.nn.CosineSimilarity(dim=1)(direction.reshape(
         (1, -1, 1, 1)), layer_t).mean()