コード例 #1
0
            print "Error: the argument %s has to be specified" % (arg)
            exit(1)

    # mandatory arguments
    in_scp_file = arguments['in_scp_file']
    out_ark_file = arguments['out_ark_file']
    lstm_param_file = arguments['lstm_param_file']
    lstm_cfg_file = arguments['lstm_cfg_file']
    layer_index = int(arguments['layer_index'])

    # network structure
    cfg = cPickle.load(open(lstm_cfg_file, 'r'))
    cfg.init_activation()

    kaldiread = KaldiReadIn(in_scp_file)
    kaldiwrite = KaldiWriteOut(out_ark_file)

    log('> ... setting up the ATTEND LSTM layers')
    rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(rng.randint(2**30))

    lstm = ATTEND_LSTM(numpy_rng=rng, theano_rng=theano_rng, cfg=cfg)
    _file2nnet(layers=lstm.layers,
               set_layer_num=len(lstm.layers),
               filename=lstm_param_file)
    out_function = lstm.build_extract_feat_function()

    while True:
        uttid, in_matrix = kaldiread.read_next_utt()
        if uttid == '':
            break
コード例 #2
0
ファイル: run_CnnFeat_sy.py プロジェクト: synetkim/multi_asr
    # network structure
    cfg = cPickle.load(open(cnn_cfg_file,'r'))

    conv_configs = cfg.conv_layer_configs
    conv_layer_number = len(conv_configs)
    for i in xrange(conv_layer_number):
        conv_configs[i]['activation'] = cfg.conv_activation

    # whether to use the fast mode
    use_fast = cfg.use_fast
    if arguments.has_key('use_fast'):
        use_fast = string_2_bool(arguments['use_fast'])

    kaldiread = KaldiReadIn(in_scp_file)
    kaldiwrite = KaldiWriteOut(out_ark_file)


    log('> ... setting up the CNN convolution layers')
    input_shape_train = conv_configs[0]['input_shape']
    input_shape_1 = (input_shape_train[1], input_shape_train[2], input_shape_train[3])

    rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(rng.randint(2 ** 30))
    cfg.init_activation() 

    cnn = CNN_Forward(numpy_rng = rng, theano_rng=theano_rng, conv_layer_configs = conv_configs, use_fast = use_fast)
    #cnn = CNNV(numpy_rng = rng, theano_rng=theano_rng, cfg=cfg)
    _file2nnet(cnn.conv_layers, set_layer_num = len(conv_configs), filename=cnn_param_file)
    out_function = cnn.build_out_function()
    #out_function = cnn.build_extract_feat_function(-1)
コード例 #3
0
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg); exit(1)

    # mandatory arguments
    in_scp_file = arguments['in_scp_file']
    out_ark_file = arguments['out_ark_file']
    lstm_param_file = arguments['lstm_param_file']
    lstm_cfg_file = arguments['lstm_cfg_file']
    layer_index = int(arguments['layer_index'])

    # network structure
    cfg = cPickle.load(open(lstm_cfg_file,'r'))
    cfg.init_activation() 

    kaldiread = KaldiReadIn(in_scp_file)
    kaldiwrite = KaldiWriteOut(out_ark_file)

    log('> ... setting up the ATTEND LSTM layers')
    rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(rng.randint(2 ** 30))

    lstm = ATTEND_LSTM(numpy_rng=rng, theano_rng=theano_rng, cfg = cfg)
    _file2nnet(layers = lstm.layers, set_layer_num = len(lstm.layers), filename=lstm_param_file)
    out_function = lstm.build_extract_feat_function()

    while True:
        uttid, in_matrix = kaldiread.read_next_utt()
        if uttid == '':
            break
        print 'in_matrix:'+str(in_matrix.shape)
        final_matrix = numpy.zeros((in_matrix.shape[0],cfg.n_outs), dtype=theano.config.floatX)