<jupyter_start><jupyter_text>Interpreting Visition Transformer With Rollout Interpreters<jupyter_code>import paddle
import interpretdl as it
# load vit model and weights
!wget -c https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch16_224_pretrained.pdparams -P assets/

from assets.vision_transformer import ViT_base_patch16_224
paddle_model = ViT_base_patch16_224()
MODEL_PATH = 'assets/ViT_base_patch16_224_pretrained.pdparams'
paddle_model.set_dict(paddle.load(MODEL_PATH))
from PIL import Image
from interpretdl.data_processor.readers import read_image

img_path = 'assets/catdog.png'
x = Image.fromarray(read_image(img_path)[0])
x
rollout = it.RolloutInterpreter(paddle_model, use_cuda=False)<jupyter_output><empty_output><jupyter_text>`rollout` method is base on:$$\bar{A}^{(b)} = E_h[A^{(b)}] + I \\C = \bar{A}^{(1)}\cdot \bar{A}^{(2)}\cdot ...\cdot \bar{A}^{(B)}$$you can change the start layer to get different results<jupyter_code>heatmap = rollout.interpret(
        img_path,
        start_layer=0,
        visual=True,
        save_path=None)
# new interpretation algorithms will be implemented soon.<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12037833190025796, 'fraction_numerical': 0.02063628546861565, 'mean_word_length': 6.185185185185185, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '285047', 'license': 'Apache-2.0', 'n_tokens_mistral': 428, 'n_tokens_neox': 407, 'n_words': 78, 'path': 'tutorials/ViT_explanations_rollout.ipynb', 'repo_name': 'Wgm-Inspur/InterpretDL', 'size': '1163'}