File size: 446 Bytes
31861e5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import numpy as np
import torch, 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.')
def str2tuple(s):
return tuple(s.split('_'))
def s2ituple(s):
return tuple(int(_s) for _s in s.split('_'))
|