-
Notifications
You must be signed in to change notification settings - Fork 0
/
prelude.py
53 lines (44 loc) · 1.37 KB
/
prelude.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
import torch
from einops import rearrange, repeat
import pytorch_lightning as pl
from specialtokens import *
import torch.nn as nn
from pytorch_lightning.loggers import WandbLogger
import itertools
import os
import json
from torch import Tensor
import logging
logging.getLogger("pytorch_lightning").setLevel(logging.ERROR)
rescored_endnodes_t = tuple[Tensor, Tensor, Tensor, Tensor, Tensor]
batch_t = tuple[tuple[Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor], tuple[Tensor, Tensor, Tensor, Tensor, Tensor], tuple[Tensor, Tensor, Tensor, Tensor, Tensor]]
ALL_TARGET_LANGS_LABEL: str = 'all_target_langs'
from enum import Enum
# strategy identifiers
class STRATS(Enum):
Supv = "Supv"
SupvBst = "SupvBst"
Pi = "Pi"
PiBst = "PiBst"
Bpall = "Bpall"
BpallBst = "BpallBst"
BpallPi = "BpallPi"
BpallPiBst = "BpallPiBst"
class DATASETS(Enum):
NRO_IPA = "Nromance_ipa"
WIKIHAN = "chinese_wikihan2022"
import argparse
def str2bool(v):
if isinstance(v, bool):
return v
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
return False
else:
raise argparse.ArgumentTypeError('Boolean value expected.')
class LabelStatus(Enum):
UNLABELLED = 0
PSEUDOLABEL = 1
LABELLED = 2
REVEALED = 3 # was hidden but revealed for evaluation