lucid/scratch/rl_util/attribution.py [51:72]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
):
    with tf.Graph().as_default(), tf.Session(), gradient_override_map(override or {}):
        t_obses = tf.placeholder_with_default(
            obses.astype(np.float32), (None, None, None, None)
        )
        T = render.import_model(model, t_obses, t_obses)
        t_acts = T(layer_name)
        if prev_layer_name is None:
            t_acts_prev = t_obses
        else:
            t_acts_prev = T(prev_layer_name)
        if act_dir is not None:
            t_acts = act_dir[None, None, None] * t_acts
        if act_poses is not None:
            t_acts = tf.gather_nd(
                t_acts,
                tf.concat([tf.range(obses.shape[0])[..., None], act_poses], axis=-1),
            )
        t_scores = score_fn(t_acts)
        assert len(t_scores.shape) >= 1, "score_fn should not reduce the batch dim"
        t_score = tf.reduce_sum(t_scores)
        t_grad = tf.gradients(t_score, [t_acts_prev])[0]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



lucid/scratch/rl_util/attribution.py [159:180]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
):
    with tf.Graph().as_default(), tf.Session(), gradient_override_map(override or {}):
        t_obses = tf.placeholder_with_default(
            obses.astype(np.float32), (None, None, None, None)
        )
        T = render.import_model(model, t_obses, t_obses)
        t_acts = T(layer_name)
        if prev_layer_name is None:
            t_acts_prev = t_obses
        else:
            t_acts_prev = T(prev_layer_name)
        if act_dir is not None:
            t_acts = act_dir[None, None, None] * t_acts
        if act_poses is not None:
            t_acts = tf.gather_nd(
                t_acts,
                tf.concat([tf.range(obses.shape[0])[..., None], act_poses], axis=-1),
            )
        t_scores = score_fn(t_acts)
        assert len(t_scores.shape) >= 1, "score_fn should not reduce the batch dim"
        t_score = tf.reduce_sum(t_scores)
        t_grad = tf.gradients(t_score, [t_acts_prev])[0]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



