Blame view
Scripts/utils/nnet/.svn/text-base/gen_dct_mat.py.svn-base
1.13 KB
ec85f8892 first commit |
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 |
#!/usr/bin/python -u # ./gen_dct_mat.py # script generates matrix with DCT transform # # author: Karel Vesely # from math import * import sys from optparse import OptionParser parser = OptionParser() parser.add_option('--fea-dim', dest='dim', help='feature dimension') parser.add_option('--splice', dest='splice', help='applied splice value') parser.add_option('--dct-basis', dest='dct_basis', help='number of DCT basis') (options, args) = parser.parse_args() if(options.dim == None): parser.print_help() sys.exit(1) dim=int(options.dim) splice=int(options.splice) dct_basis=int(options.dct_basis) timeContext=2*splice+1 #generate the DCT matrix M_PI = 3.1415926535897932384626433832795 M_SQRT2 = 1.4142135623730950488016887 #generate small DCT matrix print '[' for k in range(dct_basis): for m in range(dim): for n in range(timeContext): if(n==0): print m*'0 ', else: print (dim-1)*'0 ', print str(sqrt(2.0/timeContext)*cos(M_PI/timeContext*k*(n+0.5))), if(n==timeContext-1): print (dim-m-1)*'0 ', print print print ']' |