forked from MiloQ/MELD-Sentiment-Analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
56 lines (46 loc) · 1.76 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from setting import config
from utils.data import get_data
from torch.utils.data import DataLoader
from utils.multi import multi_data_collator
from finetuning.train import train_model
from utils.bert import bert_data_collator
from utils.hubert import hubert_data_collator
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
cfg = config.DefaultConfig()
print("Start Loading Data........")
train_dataset = get_data(data_use="train",mode=cfg.mode)
dev_dataset = get_data(data_use="dev",mode=cfg.mode)
test_dataset = get_data(data_use="test",mode=cfg.mode)
if cfg.mode == "multi":
train_dataloader = DataLoader(
train_dataset,batch_size=cfg.batchsize,collate_fn=multi_data_collator
)
eval_dataloader = DataLoader(
dev_dataset,batch_size = cfg.batchsize,collate_fn=multi_data_collator
)
test_dataloader = DataLoader(
test_dataset,batch_size= cfg.batchsize,collate_fn=multi_data_collator
)
elif cfg.mode == "text":
train_dataloader = DataLoader(
train_dataset, batch_size=cfg.batchsize,collate_fn=bert_data_collator
)
eval_dataloader = DataLoader(
dev_dataset, batch_size=cfg.batchsize, collate_fn=bert_data_collator
)
test_dataloader = DataLoader(
test_dataset, batch_size=cfg.batchsize, collate_fn=bert_data_collator
)
elif cfg.mode == "audio":
train_dataloader = DataLoader(
train_dataset, batch_size=cfg.batchsize,collate_fn=hubert_data_collator
)
eval_dataloader = DataLoader(
dev_dataset, batch_size=cfg.batchsize,collate_fn=hubert_data_collator
)
test_dataloader = DataLoader(
test_dataset, batch_size=cfg.batchsize,collate_fn=hubert_data_collator
)
if __name__ == "__main__":
train_model(cfg,train_dataloader,eval_dataloader,test_dataloader)