elshehawy commited on
Commit
bd5687f
β€’
1 Parent(s): 37b391d

use 100 examples of test set

Browse files
Files changed (1) hide show
  1. evaluate_data.py +5 -3
evaluate_data.py CHANGED
@@ -1,5 +1,5 @@
1
  from evaluate_model import compute_metrics
2
- from datasets import load_from_disk
3
  from transformers import AutoTokenizer
4
  import os
5
  import pickle
@@ -22,6 +22,7 @@ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
22
  data_path = './data/merged_dataset/'
23
 
24
  test = load_from_disk(data_path)['test']
 
25
 
26
  feature_path = './data/ner_feature.pickle'
27
 
@@ -53,15 +54,16 @@ def collate_fn(data):
53
 
54
  return input_ids, token_type_ids, attention_mask, labels
55
 
56
- loader = torch.utils.data.DataLoader(tokenized_test, batch_size=32, collate_fn=collate_fn)
57
  device = torch.device('cuda:0') if torch.cuda.is_available() else torch.device('cpu')
58
- print(device)
59
 
60
  ner_model = ner_model.eval()
61
 
62
 
63
 
64
  def get_metrics_trf():
 
 
65
  y_true, logits = [], []
66
 
67
  for input_ids, token_type_ids, attention_mask, labels in tqdm(loader):
 
1
  from evaluate_model import compute_metrics
2
+ from datasets import load_from_disk, Dataset
3
  from transformers import AutoTokenizer
4
  import os
5
  import pickle
 
22
  data_path = './data/merged_dataset/'
23
 
24
  test = load_from_disk(data_path)['test']
25
+ test = Dataset.from_dict(test[:105])
26
 
27
  feature_path = './data/ner_feature.pickle'
28
 
 
54
 
55
  return input_ids, token_type_ids, attention_mask, labels
56
 
57
+ loader = torch.utils.data.DataLoader(tokenized_test, batch_size=16, collate_fn=collate_fn)
58
  device = torch.device('cuda:0') if torch.cuda.is_available() else torch.device('cpu')
 
59
 
60
  ner_model = ner_model.eval()
61
 
62
 
63
 
64
  def get_metrics_trf():
65
+ print(device)
66
+
67
  y_true, logits = [], []
68
 
69
  for input_ids, token_type_ids, attention_mask, labels in tqdm(loader):