Beispiel #1
0
def loadass():
    dlog = icfg.getdir('log')
    ass = idlabpro.PData()
    nld = None
    ftst = icfg.readflst('test')
    cls = icls.getcls(ftst)
    for fn in sorted(os.listdir(dlog)):
        if not re.match('hmm-0_0_assess\.', fn): continue
        ass.Restore(os.path.join(dlog, fn))
        ass.Select(ass, 0, 1)
        dat = ass.tonumpy().reshape((1, -1))
        if nld is None: nld = dat
        else: nld = np.concatenate((nld, dat), axis=0)
    if len(ftst) != nld.shape[-1]:
        raise ValueError("test.flst and assess missmatch in len")
    return (ftst, nld)
Beispiel #2
0
def argv2resfns(pat, fns):
    dlog = icfg.getdir('log')
    fns = [*fns]
    if len(fns) == 0: fns = [dlog]
    i = 0
    while i < len(fns):
        if not os.path.exists(fns[i]): fns[i] = os.path.join(dlog, fns[i])
        if os.path.isdir(fns[i]):
            ins = [
                os.path.join(fns[i], f) for f in os.listdir(fns[i])
                if f[:len(pat)] == pat and f[-4:] == '.npy'
            ]
            fns = fns[:i] + ins + fns[i + 1:]
            i += len(ins)
        else:
            i += 1
    return fns
Beispiel #3
0
import numpy as np
import os
import sys
import importlib

sys.path.append(os.environ['UASR_HOME'] + '-py')

import ipl
import icfg
import idnn

if len(sys.argv) < 2: raise ValueError("Usage: " + sys.argv[0] + " CFG {PAR}")
icfg.Cfg(sys.argv[1])

dlog = icfg.getdir('log')
dn = os.path.join(dlog, 'dnnrnd')

res = []
for fn in os.listdir(dn):
    if fn[-8:] != '_arg.npy': continue
    fna = os.path.join(dn, fn)
    res.append({'fna': fna})
    fns = fna[:-8] + '_stat.npy'
    if os.path.exists(fns): res[-1]['fns'] = fns
    fnx = fna[:-8] + '_stat_allsen.npy'
    if os.path.exists(fnx): res[-1]['fnx'] = fnx
    res[-1]['fnp'] = fna[:-8] + '_par.npy'


def arg2par(arg):
Beispiel #4
0
def sigget(f):
    dsig = icfg.getdir('sig')
    sigext = '.' + icfg.get('sig.ext', 'wav')
    sig = isig.load(os.path.join(dsig, f['fn'] + sigext)).rmaxis()
    sig.inc = [1 / icfg.get('sig.srate')]
    return sig
Beispiel #5
0
        stat.append(np.array(r['stat']))
    print('/dnnrnd_'+str(int(time.time())))
    np.save(dlog+'/dnnrnd/dnnrnd_'+str(int(time.time()))+'_arg.npy',kwargs)
    np.save(dlog+'/dnnrnd/dnnrnd_'+str(int(time.time()))+'_par.npy',xpar)
    if len(stat)==3: np.save(dlog+'/dnnrnd/dnnrnd_'+str(int(time.time()))+'_stat.npy',stat)

def dnnrndloop():
    while not os.path.exists('stop'): dnnrnd()

if len(sys.argv)<2: raise ValueError("Usage: "+sys.argv[0]+" CFG [-n]")
icfg.Cfg(*sys.argv[1:])

ftrn=icfg.readflst('train')
ftst=icfg.readflst('test')

dmod=icfg.getdir('model')
dlog=icfg.getdir('log')
sen=getsensors()
regression=icfg.get('trn.regression')==True

senuse=sen
feause=['pfa','sfa','sig']
clsuse=['hmm','svm','cnnb','cnn','dnn']
if not icfg.get('senuse') is None: senuse=icfg.get('senuse').split(',')
if not icfg.get('feause') is None: feause=icfg.get('feause').split(',')
if not icfg.get('clsuse') is None: clsuse=icfg.get('clsuse').split(',')

labmap={}
if icfg.get('db')=='izfp/cfk': labmap={'Z0[0-2]':'Z00'}

maxjob=18