Skip to content

Commit 00a4353

Browse files
authored
Merge pull request #57 from tudelft-cda-lab/RB/remove_legacy_files
Removed legacy files
2 parents c9c1540 + c98625c commit 00a4353

10 files changed

Lines changed: 0 additions & 2360 deletions

source/active_learning/system_under_learning/neural_network_suls/python/connectors/lsharp_connector_transformer.py

Lines changed: 0 additions & 199 deletions
This file was deleted.

source/active_learning/system_under_learning/neural_network_suls/python/connectors/paul_connector_batch.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
"""
2-
Like the binary state causal transformer connector, but also returns confidence of transformer as well.
3-
42
Documentation of CPython-API: https://docs.python.org/3/c-api/index.html
53
64
Created by Robert Baumgartner, 10.9.24.
@@ -113,35 +111,6 @@ def make_tensor_causal_masks(words:torch.Tensor):
113111
x += torch.eye(l,dtype=torch.bool, device=x.device)
114112
return x.type(torch.int8)
115113

116-
117-
def get_representation(output, last_token_idx):
118-
"""Gets the attention. Make sure to keep the convention: Keys go from 1...number of attention vectors,
119-
as 0 is reserved for the networks output.
120-
121-
Returns:
122-
output (dict): 1...n_attn -> attn_vector
123-
"""
124-
DO_FIRST_ONLY = True
125-
126-
if DO_FIRST_ONLY:
127-
attn = torch.squeeze(output["hidden_states"][1].detach().cpu()).numpy() # (b_size, maxlen_seq, hidden_dim); b_size here will always be 1 and squeezed out!
128-
#attn = torch.squeeze(output["attentions"][0].detach()).numpy() # (b_size, n_heads, maxlen_seq, maxlen_seq); b_size here will always be 1 and squeezed out!
129-
#attn = np.mean(attn, axis=0) # using the attn and not the states
130-
elif False:
131-
pass # placeholder for different strategy
132-
else: # concatenate all of them
133-
attn = output.hidden_states[1].detach().cpu()
134-
for i in range(2, len(output.hidden_states)):
135-
attn = torch.cat((attn, output.hidden_states[i]), dim=-1)
136-
attn = torch.squeeze(attn.detach().detach().cpu()).numpy()
137-
138-
res = list()
139-
for i in range(last_token_idx+1):
140-
res.extend(list(attn[i]))
141-
142-
return res
143-
144-
145114
def do_query(input_seq: list):
146115
"""This is the main function, performed on a sequence.
147116
Returns what you want it to return, make sure it makes
@@ -198,9 +167,6 @@ def do_query(input_seq: list):
198167
res.append(pred_type)
199168
res.append(confidence.item())
200169

201-
#representations = get_representation(output, last_token_idx)
202-
#embedding_dim = int(len(representations) / len(seq))
203-
204170
return res
205171

206172

@@ -267,22 +233,4 @@ def get_types():
267233
raise Exception("Should not be called, PAUL does not need this")
268234

269235
if __name__ == "__main__":
270-
import random
271-
272-
# {'c': 0, 'b': 1, 'd': 2, 'a': 3}
273-
model_path = "/home/robert/Documents/code/Flexfringe/data/active_learning/mlregtest/trained_models/distilbert_problem_04.04.SL.2.1.0_mid.pk.finetuned"
274-
get_alphabet(model_path)
275-
load_nn_model(model_path)
276-
277-
i = 0
278-
symbols = ["a", "b", "c", "d"]
279-
while True:
280-
length = random.randint(0, 25)
281-
b_size = random.randint(1, 512)
282-
seq = [[random.choice(symbols) for _ in range(length)] for _ in range(b_size)]
283-
res = do_query(seq)
284-
i += 1
285-
if i % 100 == 0:
286-
print(i)
287-
288236
raise Exception("This is not a standalone script.")

source/active_learning/system_under_learning/neural_network_suls/python/connectors/todo_refactor/nn_connector_taysir_track_1.py

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)