-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
100 lines (86 loc) · 2.74 KB
/
config.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import os
import torch
from dataclasses import dataclass
@dataclass
class Config:
seed = 2024
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
vocab_size = 7500
word_emb_dim = 512
hidden_dim = 1024
num_lstm_layers = 1
num_gpt1_layers = 6
n_head = 8
batch = 32
epoch = 10
lr_lstm = 5e-4
lr_gpt1 = 2e-4
train_size = 0.8
max_length = 128
dataset_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'dataset', 'Flick_30k')
image_dir = os.path.join(dataset_dir, 'Images')
caption_file = os.path.join(dataset_dir, 'captions.txt')
vocab_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'vocab' + str(vocab_size) + '.txt')
@property
def encoder_lstm_file(self) -> str:
return (
'src/encoder' +
'_b' + str(self.batch) +
'_h' + str(self.hidden_dim) +
'_l' + str(self.num_lstm_layers) +
'_e' + str(self.epoch) +
'_lstm.pt'
)
@property
def decoder_lstm_file(self) -> str:
return (
'src/decoder' +
'_b' + str(self.batch) +
'_h' + str(self.hidden_dim) +
'_l' + str(self.num_lstm_layers) +
'_e' + str(self.epoch) +
'_lstm.pt'
)
@property
def embedding_lstm_file(self) -> str:
return (
'src/embedding' +
'_b' + str(self.batch) +
'_h' + str(self.hidden_dim) +
'_l' + str(self.num_lstm_layers) +
'_e' + str(self.epoch) +
'_lstm.pt'
)
@property
def encoder_gpt1_file(self) -> str:
return (
'src/encoder' +
'_b' + str(self.batch) +
'_h' + str(self.hidden_dim) +
'_l' + str(self.num_gpt1_layers) +
'_nh' + str(self.n_head) +
'_e' + str(self.epoch) +
'_gpt1.pt'
)
@property
def decoder_gpt1_file(self) -> str:
return (
'src/decoder' +
'_b' + str(self.batch) +
'_h' + str(self.hidden_dim) +
'_l' + str(self.num_gpt1_layers) +
'_nh' + str(self.n_head) +
'_e' + str(self.epoch) +
'_gpt1.pt'
)
@property
def embedding_gpt1_file(self) -> str:
return (
'src/embedding' +
'_b' + str(self.batch) +
'_h' + str(self.hidden_dim) +
'_l' + str(self.num_gpt1_layers) +
'_nh' + str(self.n_head) +
'_e' + str(self.epoch) +
'_gpt1.pt'
)