-
-
Notifications
You must be signed in to change notification settings - Fork 376
/
Copy pathconfig.py
170 lines (147 loc) · 3.92 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
'''
Model Configuration
'''
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
from shutil import copyfile
import os
import SharedArray as sa
import tensorflow as tf
import glob
print('[*] config...')
# class Dataset:
TRACK_NAMES = ['bass', 'drums', 'guitar', 'piano', 'strings']
def get_colormap():
colormap = np.array([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.],
[1., .5, 0.],
[0., .5, 1.]])
return tf.constant(colormap, dtype=tf.float32, name='colormap')
###########################################################################
# Training
###########################################################################
class TrainingConfig:
is_eval = True
batch_size = 64
epoch = 20
iter_to_save = 100
sample_size = 64
print_batch = True
drum_filter = np.tile([1,0.3,0,0,0,0.3], 16)
scale_mask = [1., 0., 1., 0., 1., 1., 0., 1., 0., 1., 0., 1.]
inter_pair = [(0,2), (0,3), (0,4), (2,3), (2,4), (3,4)]
track_names = TRACK_NAMES
track_dim = len(track_names)
eval_map = np.array([
[1, 1, 1, 1, 1], # metric_is_empty_bar
[1, 1, 1, 1, 1], # metric_num_pitch_used
[1, 0, 1, 1, 1], # metric_too_short_note_ratio
[1, 0, 1, 1, 1], # metric_polyphonic_ratio
[1, 0, 1, 1, 1], # metric_in_scale
[0, 1, 0, 0, 0], # metric_drum_pattern
[1, 0, 1, 1, 1] # metric_num_chroma_used
])
exp_name = 'exp'
gpu_num = '1'
###########################################################################
# Model Config
###########################################################################
class ModelConfig:
output_w = 96
output_h = 84
lamda = 10
batch_size = 64
beta1 = 0.5
beta2 = 0.9
lr = 2e-4
is_bn = True
colormap = get_colormap()
# image
class MNISTConfig(ModelConfig):
output_w = 28
output_h = 28
z_dim = 74
output_dim = 1
# RNN
class RNNConfig(ModelConfig):
track_names = ['All']
track_dim = 1
output_bar = 4
z_inter_dim = 128
output_dim = 5
acc_idx = None
state_size = 128
# onebar
class OneBarHybridConfig(ModelConfig):
track_names = TRACK_NAMES
track_dim = 5
acc_idx = None
z_inter_dim = 64
z_intra_dim = 64
output_dim = 1
class OneBarJammingConfig(ModelConfig):
track_names = TRACK_NAMES
track_dim = 5
acc_idx = None
z_intra_dim = 128
output_dim = 1
class OneBarComposerConfig(ModelConfig):
track_names = ['All']
track_dim = 1
acc_idx = None
z_inter_dim = 128
output_dim = 5
# nowbar
class NowBarHybridConfig(ModelConfig):
track_names = TRACK_NAMES
track_dim = 5
acc_idx = 4
z_inter_dim = 64
z_intra_dim = 64
output_dim = 1
class NowBarJammingConfig(ModelConfig):
track_names = TRACK_NAMES
track_dim = 5
acc_idx = 4
z_intra_dim = 128
output_dim = 1
class NowBarComposerConfig(ModelConfig):
track_names = ['All']
track_dim = 1
acc_idx = 4
z_inter_dim = 128
output_dim = 5
# Temporal
class TemporalHybridConfig(ModelConfig):
track_names = TRACK_NAMES
track_dim = 5
output_bar = 4
z_inter_dim = 32
z_intra_dim = 32
acc_idx = None
output_dim = 1
class TemporalJammingConfig(ModelConfig):
track_names = TRACK_NAMES
track_dim = 5
output_bar = 4
z_intra_dim = 64
output_dim = 1
class TemporalComposerConfig(ModelConfig):
track_names = ['All']
track_dim = 1
output_bar = 4
z_inter_dim = 64
acc_idx = None
output_dim = 5
class NowBarTemporalHybridConfig(ModelConfig):
track_names = TRACK_NAMES
acc_idx = 4
track_dim = 5
output_bar = 4
z_inter_dim = 32
z_intra_dim = 32
acc_idx = 4
output_dim = 1