-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
35 lines (32 loc) · 1.01 KB
/
util.py
File metadata and controls
35 lines (32 loc) · 1.01 KB
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
import argparse
import numpy as np
import os
import random
import subprocess
import time
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import sys
from transformers import BertModel, BertTokenizer
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
def format_time(start, end, total=None, finish=None):
if total and finish:
run_time = end - start
total_time = run_time * total / finish
todo_time = total_time - run_time
run_h = run_time // 3600
run_m = run_time % 3600 // 60
run_s = run_time % 60
todo_h = todo_time // 3600
todo_m = todo_time % 3600 // 60
todo_s = todo_time % 60
ret = '%02d:%02d:%02d>%02d:%02d:%02d' % (todo_h, todo_m, todo_s, run_h, run_m, run_s)
else:
run_time = end - start
run_h = run_time // 3600
run_m = run_time % 3600 // 60
run_s = run_time % 60
ret = '%02d:%02d:%02d' % (run_h, run_m, run_s)
return ret