Example #1
0
 def inner(T):
     t_acts = T(layer)
     t_shp = tf.shape(t_acts)
     v_shp = vec.shape
     M1 = (t_shp[1] - v_shp[1]) // 2
     M2 = (t_shp[2] - v_shp[2]) // 2
     t_acts_ = t_acts[:, M1:M1 + v_shp[1], M2:M2 + v_shp[2], :]
     return _dot_cossim(t_acts_, vec, cossim_pow=cossim_pow)
Example #2
0
def direction(layer, vec, cossim_pow=0):
    """Visualize a direction"""
    vec = vec[None, None, None]
    vec = vec.astype("float32")
    return lambda T: _dot_cossim(T(layer), vec, cossim_pow=cossim_pow)
Example #3
0
 def inner(T):
     layer = T(layer_name)
     layer = _extract_act_pos(layer, x, y)
     return _dot_cossim(layer, vec[None, None, None], cossim_pow=cossim_pow)
Example #4
0
 def inner(T):
   return _dot_cossim(T(layer), vec, cossim_pow=cossim_pow)