MCPcopy Create free account
hub / github.com/HealthX-Lab/MedCLIP-SAMv2 / extract_bert_layer

Function extract_bert_layer

saliency_maps/scripts/methods.py:26–34  ·  view source on GitHub ↗
(model, layer_idx)

Source from the content-addressed store, hash-verified

24
25# Extract BERT Layer
26def extract_bert_layer(model, layer_idx):
27 desired_layer = ''
28 for _, submodule in model.named_children():
29 for n, s in submodule.named_children():
30 if n == 'layers' or n == 'resblocks':
31 for n2, s2 in s.named_children():
32 if n2 == str(layer_idx):
33 desired_layer = s2
34 return desired_layer
35
36# Get an estimator for the compression term
37def get_compression_estimator(var, layer, features):

Callers 2

text_heatmap_ibaFunction · 0.85
vision_heatmap_ibaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected