analyze_cmd.add_argument( "--dataset", type=str, default='swbd_verification', choices=['swbd_recognition', 'swbd_verification', 'swbd_short'], help="Which dataset to use") rng = numpy.random.RandomState(1) args = ap.parse_args() t_start = time.time() if args.cmd == 'analyze': batchsize = args.batchsize filename = args.load_from print "load from %s" % filename # model = pickle.load(open(filename,'rb')) model = NN_parallel({}, njobs=1) model.load(filename) npz_tst = numpy.load( "/data2/tawara/work/ttic/data/icassp15.0/swbd.test.npz") npz_trn = numpy.load( "/data2/tawara/work/ttic/data/icassp15.0/swbd.train.npz") utt_ids_trn = sorted(npz_trn.keys()) utt_ids_tst = sorted(npz_tst.keys()) x_train = numpy.array([npz_trn[i] for i in utt_ids_trn]).astype(numpy.float32) x_test = numpy.array([npz_tst[i] for i in utt_ids_tst]).astype(numpy.float32) tmp = [] for l in x_test: tmp.append([l]) x_test = numpy.array(tmp)
ali_to_pdf=KaldiCommand('bin/ali-to-pdf', option='/data2/tawara/work/ttic/MyPython/src/kaldi/timit/exp/tri3_ali/final.mdl') # feats=KaldiCommand('featbin/apply-cmvn', '--norm-means=true --norm-vars=true --utt2spk=ark:/data2/tawara/work/ttic/MyPython/src/kaldi/timit/data/fbank/train_tr90/utt2spk scp:/data2/tawara/work/ttic/MyPython/src/kaldi/timit/data/fbank/train_tr90/cmvn.scp') x_train, y_train = load_timit_labelled_kaldi(\ # feats('/data2/tawara/work/ttic/MyPython/src/kaldi/timit/data/fbank/train_tr90/feats.scp'), KaldiArk('/data2/tawara/work/ttic/MyPython/src/kaldi/timit/feats_cmvn.ark'), ali_to_pdf('\"gunzip -c /data2/tawara/work/ttic/MyPython/src/kaldi/timit/exp/tri3_ali/ali.*.gz |\"'), \ nnet_transf = '/data2/tawara/work/ttic/MyPython/src/kaldi/timit/final.feature_transform') feats=KaldiCommand('featbin/apply-cmvn', '--norm-means=true --norm-vars=true --utt2spk=ark:/data2/tawara/work/ttic/MyPython/src/kaldi/timit/data/fbank/train_cv10/utt2spk scp:/data2/tawara/work/ttic/MyPython/src/kaldi/timit/data/fbank/train_cv10/cmvn.scp') x_valid, y_valid = load_timit_labelled_kaldi( \ feats('/data2/tawara/work/ttic/MyPython/src/kaldi/timit/data/fbank/train_cv10/feats.scp'), ali_to_pdf('\"gunzip -c /data2/tawara/work/ttic/MyPython/src/kaldi/timit/exp/tri3_ali/ali.*.gz |\"'), \ nnet_transf = '/data2/tawara/work/ttic/MyPython/src/kaldi/timit/final.feature_transform') model = NN_parallel(option_dict, njobs=1) nnet_file='/data2/tawara/work/ttic/MyPython/src/kaldi/timit/exp/fbank/dnn4_nn5_1024_cmvn_splice10_pretrain-dbn_dnn/nnet_dbn_dnn.init' if nnet_file is not None: model.load_parameters_from_nnet(nnet_file) model.initialize() N_train_all = x_train.shape[0] indexes_l = range(N_train_all) indexes_ul = list(set(range(0,N_train_all))-set(indexes_l)) N_train_l = len(indexes_l) N_train_ul = len(indexes_ul) assert N_train_all == N_train_l + N_train_ul N_valid = x_valid.shape[0] indexes_valid = range(0, N_valid) for epoch in xrange(n_epoch):
analyze_cmd.add_argument("--data_type", type=str, default='test', help="Data type to evaluate on") analyze_cmd.add_argument("--save_to", type=str, default='noname', help="Destination to save the state and results") analyze_cmd.add_argument("--layer", type=int, default=0, help="Extract layer") analyze_cmd.add_argument("--batchsize", type=int, default=default_options_dict['batch_size'], help="batchsize") analyze_cmd.add_argument("--dataset", type=str, default='swbd_verification', choices=['swbd_recognition', 'swbd_verification', 'swbd_short'], help="Which dataset to use") rng = numpy.random.RandomState(1) args = ap.parse_args() t_start = time.time() if args.cmd == 'analyze': batchsize = args.batchsize filename = args.load_from print "load from %s" % filename # model = pickle.load(open(filename,'rb')) model = NN_parallel({}, njobs=1) model.load(filename) npz_tst = numpy.load("/data2/tawara/work/ttic/data/icassp15.0/swbd.test.npz") npz_trn = numpy.load("/data2/tawara/work/ttic/data/icassp15.0/swbd.train.npz") utt_ids_trn = sorted(npz_trn.keys()) utt_ids_tst = sorted(npz_tst.keys()) x_train = numpy.array([npz_trn[i] for i in utt_ids_trn]).astype(numpy.float32) x_test = numpy.array([npz_tst[i] for i in utt_ids_tst]).astype(numpy.float32) tmp=[] for l in x_test: tmp.append([l]) x_test=numpy.array(tmp) tmp=[] for l in x_train: tmp.append([l]) x_train=numpy.array(tmp)