-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
51 lines (41 loc) · 1.6 KB
/
Copy pathconfig.py
File metadata and controls
51 lines (41 loc) · 1.6 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# coding:utf8
import warnings
import torch as t
import numpy as np
class DefaultConfig(object):
env = 'text_new' # visdom environment
vis_port = 8099 # visdom port num
model = 'ResNet34'# 'WaveletNet' # model used whose name should consist with the name in 'models/__init__.py'
data_root = './data/text_data/'
train_txt_path = './data/train_image_paths.txt'
val_txt_path = './data/val_image_paths.txt'
load_model_path = None
test_model_path = './checkpoints/text_new_20.pth'
test_image_path = './data/test_text_data'
gpu_device_index = '0'
batch_size = 4 # batch size
val_batch_size = 1
use_gpu = True # user GPU or not
num_workers = 0 # how many workers for loading data
print_freq = 10 # print info every N batch
save_model_freq = 2 #how many epoch to save model
debug_file = '/tmp/debug' # if os.path.exists(debug_file): enter ipdb
result_file = 'result.csv'
max_epoch = 401
lr = 0.001 # initial learning rate
lr_decay = 0.5 # when val_loss increase, lr = lr*lr_decay
weight_decay = 0e-5 #
def _parse(self, kwargs):
"""
update parameter in config file
"""
for k, v in kwargs.items():
if not hasattr(self, k):
warnings.warn("Warning: opt has not attribut %s" % k)
setattr(self, k, v)
opt.device =t.device('cuda') if opt.use_gpu else t.device('cpu')
print('user config:')
for k, v in self.__class__.__dict__.items():
if not k.startswith('_'):
print(k, getattr(self, k))
opt = DefaultConfig()