Spaces:
Running
on
T4
Running
on
T4
Update models.py
Browse files
models.py
CHANGED
@@ -1,16 +1,17 @@
|
|
1 |
-
import torch
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
class TransformerVisualizer():
|
7 |
-
def __init__(self):
|
8 |
-
self.device = torch.device(
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
16 |
|
|
|
1 |
+
import torch
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
|
6 |
+
class TransformerVisualizer():
|
7 |
+
def __init__(self):
|
8 |
+
self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
9 |
+
|
10 |
+
|
11 |
+
def predict(self, task, text):
|
12 |
+
return task, text,1
|
13 |
+
|
14 |
+
|
15 |
+
def get_attention_gradient_matrix(self, task, text, target_layer):
|
16 |
+
return task, text,target_layer,1
|
17 |
|