broccoli-ml 5.1.4__tar.gz → 5.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {broccoli_ml-5.1.4 → broccoli_ml-5.2.0}/PKG-INFO +1 -1
- {broccoli_ml-5.1.4 → broccoli_ml-5.2.0}/broccoli/vit.py +2 -3
- {broccoli_ml-5.1.4 → broccoli_ml-5.2.0}/pyproject.toml +1 -1
- {broccoli_ml-5.1.4 → broccoli_ml-5.2.0}/LICENSE +0 -0
- {broccoli_ml-5.1.4 → broccoli_ml-5.2.0}/README.md +0 -0
- {broccoli_ml-5.1.4 → broccoli_ml-5.2.0}/broccoli/__init__.py +0 -0
- {broccoli_ml-5.1.4 → broccoli_ml-5.2.0}/broccoli/activation.py +0 -0
- {broccoli_ml-5.1.4 → broccoli_ml-5.2.0}/broccoli/cnn.py +0 -0
- {broccoli_ml-5.1.4 → broccoli_ml-5.2.0}/broccoli/linear.py +0 -0
- {broccoli_ml-5.1.4 → broccoli_ml-5.2.0}/broccoli/rope.py +0 -0
- {broccoli_ml-5.1.4 → broccoli_ml-5.2.0}/broccoli/tensor.py +0 -0
- {broccoli_ml-5.1.4 → broccoli_ml-5.2.0}/broccoli/transformer.py +0 -0
- {broccoli_ml-5.1.4 → broccoli_ml-5.2.0}/broccoli/utils.py +0 -0
|
@@ -549,13 +549,12 @@ class ViT(nn.Module):
|
|
|
549
549
|
def attention_logits(self, x):
|
|
550
550
|
return self.encoder.attention_logits(x)
|
|
551
551
|
|
|
552
|
-
def
|
|
552
|
+
def head_to_bos_token_attention_logits(self, x):
|
|
553
553
|
all_attention = self.attention_logits(x)
|
|
554
554
|
batch_averages = torch.mean(all_attention, dim=0, keepdim=False)
|
|
555
555
|
sequence_averages = torch.mean(batch_averages, dim=-1, keepdim=False)
|
|
556
556
|
n_bos_tokens = self.encoder.encoder[-1]._bos_tokens
|
|
557
|
-
|
|
558
|
-
return F.softmax(just_bos, dim=1) # (layer, head, bos_token)
|
|
557
|
+
return sequence_averages[:, :, :n_bos_tokens] # (layer, head, bos_token)
|
|
559
558
|
|
|
560
559
|
def reset_parameters(self):
|
|
561
560
|
self.encoder.reset_parameters()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|