-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathtrain_cgmm.py
33 lines (29 loc) · 1.2 KB
/
train_cgmm.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
#!/usr/bin/env python
# coding=utf-8
import argparse
import time
import numpy as np
from utils import MultiChannelWrapper
from cgmm import CGMMTrainer
def train(args):
wrapper = MultiChannelWrapper(args.descriptor)
(time_steps, num_bins), spectrums = wrapper.spectrums()
trainer = CGMMTrainer(num_bins, time_steps, len(spectrums))
start_time = time.time()
trainer.train(np.transpose(spectrums), iters=args.iters)
finish_time = time.time()
print('Total raining time: {:.3f}s'.format(finish_time - start_time))
trainer.save_param(args.save_dir)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Training CGMM on multiple channel")
parser.add_argument('descriptor', type=str,
help="""descriptor of multiple channel location""")
parser.add_argument('-i', '--iters',
dest='iters', type=int, default='10',
help="""number of iterations to train""")
parser.add_argument('-s', '--save',
dest='save_dir', type=str, default='.',
help="""directory to save sigma of CGMM""")
args = parser.parse_args()
train(args)