Exemplo n.º 1
0
    ]
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg)
            exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    nnet_spec = arguments['nnet_spec']
    lstm_nnet_spec = arguments['lstm_nnet_spec']
    wdir = arguments['wdir']

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig()
    cfg.model_type = 'ATTEND_LSTM'
    cfg.parse_config_attend(arguments, nnet_spec, lstm_nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)
    print 'Extra dim: ' + str(cfg.extra_dim)

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2**30))
    log('> ... building the model')
    # setup model
    dnn = PhaseATTEND_LSTM(numpy_rng=numpy_rng, theano_rng=theano_rng, cfg=cfg)

    # get the training, validation and testing function for the model
    log('> ... getting the finetuning functions')
    train_fn, valid_fn = dnn.build_finetune_functions(
        (cfg.train_x, cfg.train_y), (cfg.valid_x, cfg.valid_y),
        (cfg.extra_train_x), (cfg.extra_valid_x),
Exemplo n.º 2
0
    ]
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg)
            exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    conv_nnet_spec = arguments['conv_nnet_spec']
    nnet_spec = arguments['nnet_spec']
    wdir = arguments['wdir']

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig()
    cfg.model_type = 'CNN'
    cfg.parse_config_cnn(arguments, '10:' + nnet_spec, conv_nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)

    if arguments.has_key('replicate'):
        cfg.replicate = int(arguments['replicate'])

    # parse pre-training options
    # pre-training files and layer number (how many layers are set to the pre-training parameters)
    ptr_layer_number = 0
    ptr_file = ''
    if arguments.has_key('ptr_file') and arguments.has_key('ptr_layer_number'):
        ptr_file = arguments['ptr_file']
        temp = arguments['ptr_layer_number'].split(':')

        if len(temp) > 1 or len(temp[0].split(',')) > 1:
Exemplo n.º 3
0
    arg_elements = [sys.argv[i] for i in range(1, len(sys.argv))]
    arguments = parse_arguments(arg_elements)
    required_arguments = ['train_data', 'valid_data', 'nnet_spec', 'conv_nnet_spec', 'wdir']
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg); exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    conv_nnet_spec = arguments['conv_nnet_spec']
    nnet_spec = arguments['nnet_spec']
    wdir = arguments['wdir']

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig(); cfg.model_type = 'CNNV'
    cfg.parse_config_cnn(arguments, '10:' + nnet_spec, conv_nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)

    # parse pre-training options
    # pre-training files and layer number (how many layers are set to the pre-training parameters)
    ptr_layer_number = 0; ptr_file = ''
    if arguments.has_key('ptr_file') and arguments.has_key('ptr_layer_number'):
        ptr_file = arguments['ptr_file']
        ptr_layer_number = int(arguments['ptr_layer_number'])

    # check working dir to see whether it's resuming training
    resume_training = False
    if os.path.exists(wdir + '/nnet.tmp') and os.path.exists(wdir + '/training_state.tmp'):
        resume_training = True
        cfg.lrate = _file2lrate(wdir + '/training_state.tmp')
Exemplo n.º 4
0
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg)
            exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    si_nnet_spec = arguments['si_nnet_spec']
    si_conv_nnet_spec = arguments['si_conv_nnet_spec']
    adapt_nnet_spec = arguments['adapt_nnet_spec']
    wdir = arguments['wdir']
    init_model_file = arguments['init_model']

    # parse network configuration from arguments, and initialize data reading
    cfg_si = NetworkConfig()
    cfg_si.model_type = 'CNN'
    cfg_si.parse_config_cnn(arguments, '10:' + si_nnet_spec, si_conv_nnet_spec)
    cfg_si.init_data_reading(train_data_spec, valid_data_spec)

    # parse the structure of the i-vector network
    cfg_adapt = NetworkConfig()
    net_split = adapt_nnet_spec.split(':')
    adapt_nnet_spec = ''
    for n in xrange(len(net_split) - 1):
        adapt_nnet_spec += net_split[n] + ':'
    cfg_adapt.parse_config_dnn(arguments, adapt_nnet_spec + '0')

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2**30))
    log('> ... initializing the model')
    # setup up the model
Exemplo n.º 5
0
    arg_elements = [sys.argv[i] for i in range(1, len(sys.argv))]
    arguments = parse_arguments(arg_elements)
    required_arguments = ['train_data', 'valid_data', 'nnet_spec', 'lstm_nnet_spec', 'wdir']
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg); exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    nnet_spec = arguments['nnet_spec']
    lstm_nnet_spec = arguments['lstm_nnet_spec']
    wdir = arguments['wdir']

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig();cfg.model_type = 'ATTEND_LSTM'
    cfg.parse_config_attend(arguments, nnet_spec, lstm_nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2 ** 30))
    log('> ... building the model')
    # setup model
    dnn = ATTEND_LSTM(numpy_rng=numpy_rng, theano_rng = theano_rng, cfg = cfg)

    # get the training, validation and testing function for the model
    log('> ... getting the finetuning functions')
    train_fn, valid_fn = dnn.build_finetune_functions(
                (cfg.train_x, cfg.train_y), (cfg.valid_x, cfg.valid_y),
                batch_size=cfg.batch_size)
Exemplo n.º 6
0
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg)
            exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    conv_nnet_spec = arguments['conv_nnet_spec']
    lstm_nnet_spec = arguments['lstm_nnet_spec']
    nnet_spec = arguments['nnet_spec']
    wdir = arguments['wdir']

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig()
    cfg.model_type = 'CLDNNV'
    cfg.parse_config_cldnn(arguments, nnet_spec, conv_nnet_spec,
                           lstm_nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2**30))
    log('> ... building the model')
    # setup model
    dnn = CLDNNV(numpy_rng=numpy_rng, theano_rng=theano_rng, cfg=cfg)

    # get the training, validation and testing function for the model
    log('> ... getting the finetuning functions')
    train_fn, valid_fn = dnn.build_finetune_functions(
        (cfg.train_x, cfg.train_y), (cfg.valid_x, cfg.valid_y),
        batch_size=cfg.batch_size)
Exemplo n.º 7
0
arguments = parse_arguments(arg_elements)
required_arguments = ['train_data', 'valid_data', 'nnet_spec', 'wdir']
for arg in required_arguments:
    if arguments.has_key(arg) == False:
        print "Error: the argument %s has to be specified" % (arg)
        exit(1)

# mandatory arguments
train_data_spec = arguments['train_data']
valid_data_spec = arguments['valid_data']
nnet_spec = arguments['nnet_spec']
wdir = arguments['wdir']

# parse network configuration from arguments, and initialize data reading
cfg = NetworkConfig()
cfg.model_type = 'RNN'
cfg.parse_config_dnn(arguments, nnet_spec)
cfg.init_data_reading(train_data_spec, valid_data_spec)
print("training dataset is:", cfg.train_sets.pfile_path_list)
# parse pre-training options
# pre-training files and layer number (how many layers are set to the pre-training parameters)
ptr_layer_number = 0
ptr_file = ''
if arguments.has_key('ptr_file') and arguments.has_key('ptr_layer_number'):
    ptr_file = arguments['ptr_file']
    ptr_layer_number = int(arguments['ptr_layer_number'])

# check working dir to see whether it's resuming training
resume_training = False
if os.path.exists(wdir +
                  '/nnet.tmp') and os.path.exists(wdir +
Exemplo n.º 8
0
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg)
            exit(1)

    # mandatory arguments
    train_data_spec = arguments["train_data"]
    valid_data_spec = arguments["valid_data"]
    si_nnet_spec = arguments["si_nnet_spec"]
    si_conv_nnet_spec = arguments["si_conv_nnet_spec"]
    adapt_nnet_spec = arguments["adapt_nnet_spec"]
    wdir = arguments["wdir"]
    init_model_file = arguments["init_model"]

    # parse network configuration from arguments, and initialize data reading
    cfg_si = NetworkConfig()
    cfg_si.model_type = "CNN"
    cfg_si.parse_config_cnn(arguments, "10:" + si_nnet_spec, si_conv_nnet_spec)
    cfg_si.init_data_reading(train_data_spec, valid_data_spec)

    # parse the structure of the i-vector network
    cfg_adapt = NetworkConfig()
    net_split = adapt_nnet_spec.split(":")
    adapt_nnet_spec = ""
    for n in xrange(len(net_split) - 1):
        adapt_nnet_spec += net_split[n] + ":"
    cfg_adapt.parse_config_dnn(arguments, adapt_nnet_spec + "0")

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2 ** 30))
    log("> ... initializing the model")
    # setup up the model
Exemplo n.º 9
0
    arg_elements = [sys.argv[i] for i in range(1, len(sys.argv))]
    arguments = parse_arguments(arg_elements)
    required_arguments = ['train_data', 'valid_data', 'nnet_spec', 'lstm_nnet_spec', 'wdir']
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg); exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    nnet_spec = arguments['nnet_spec']
    lstm_nnet_spec = arguments['lstm_nnet_spec']
    wdir = arguments['wdir']

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig();cfg.model_type = 'LSTMV'
    cfg.parse_config_ldnn(arguments, nnet_spec, lstm_nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2 ** 30))
    log('> ... building the model')
    # setup model
    dnn = LSTMV(numpy_rng=numpy_rng, theano_rng = theano_rng, cfg = cfg)

    # get the training, validation and testing function for the model
    log('> ... getting the finetuning functions')
    train_fn, valid_fn = dnn.build_finetune_functions(
                (cfg.train_x, cfg.train_y), (cfg.valid_x, cfg.valid_y),
                batch_size=cfg.batch_size)
Exemplo n.º 10
0
    ]
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg)
            exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    nnet_spec = arguments['nnet_spec']
    lstm_nnet_spec = arguments['lstm_nnet_spec']
    wdir = arguments['wdir']

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig()
    cfg.model_type = 'LSTMV'
    cfg.parse_config_ldnn(arguments, nnet_spec, lstm_nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2**30))
    log('> ... building the model')
    # setup model
    dnn = LSTMV(numpy_rng=numpy_rng, theano_rng=theano_rng, cfg=cfg)

    # get the training, validation and testing function for the model
    log('> ... getting the finetuning functions')
    train_fn, valid_fn = dnn.build_finetune_functions(
        (cfg.train_x, cfg.train_y), (cfg.valid_x, cfg.valid_y),
        batch_size=cfg.batch_size)
Exemplo n.º 11
0
    # check the arguments
    arg_elements = [sys.argv[i] for i in range(1, len(sys.argv))]
    arguments = parse_arguments(arg_elements)
    required_arguments = ['train_data', 'valid_data', 'nnet_spec', 'wdir']
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg); exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    nnet_spec = arguments['nnet_spec']
    wdir = arguments['wdir']

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig();cfg.model_type = 'DNNV'
    cfg.parse_config_dnn(arguments, nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)

    # parse pre-training options
    # pre-training files and layer number (how many layers are set to the pre-training parameters)
    ptr_layer_number = 0; ptr_file = ''
    if arguments.has_key('ptr_file') and arguments.has_key('ptr_layer_number'):
        ptr_file = arguments['ptr_file']
        ptr_layer_number = int(arguments['ptr_layer_number'])

    # check working dir to see whether it's resuming training
    resume_training = False
    if os.path.exists(wdir + '/nnet.tmp') and os.path.exists(wdir + '/training_state.tmp'):
        resume_training = True
        cfg.lrate = _file2lrate(wdir + '/training_state.tmp')
Exemplo n.º 12
0
    required_arguments = ["train_data", "valid_data", "nnet_spec", "conv_nnet_spec", "wdir"]
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg)
            exit(1)

    # mandatory arguments
    train_data_spec = arguments["train_data"]
    valid_data_spec = arguments["valid_data"]
    conv_nnet_spec = arguments["conv_nnet_spec"]
    nnet_spec = arguments["nnet_spec"]
    wdir = arguments["wdir"]

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig()
    cfg.model_type = "CNN"
    cfg.parse_config_cnn(arguments, "10:" + nnet_spec, conv_nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)

    # parse pre-training options
    # pre-training files and layer number (how many layers are set to the pre-training parameters)
    ptr_layer_number = 0
    ptr_file = ""
    if arguments.has_key("ptr_file") and arguments.has_key("ptr_layer_number"):
        ptr_file = arguments["ptr_file"]
        ptr_layer_number = int(arguments["ptr_layer_number"])

    # check working dir to see whether it's resuming training
    resume_training = False
    if os.path.exists(wdir + "/nnet.tmp") and os.path.exists(wdir + "/training_state.tmp"):
        resume_training = True
Exemplo n.º 13
0
    ]
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg)
            exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    conv_nnet_spec = arguments['conv_nnet_spec']
    nnet_spec = arguments['nnet_spec']
    wdir = arguments['wdir']

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig()
    cfg.model_type = 'CRNV'
    cfg.parse_config_cnn(arguments, '10:' + nnet_spec, conv_nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)

    # parse pre-training options
    # pre-training files and layer number (how many layers are set to the pre-training parameters)
    ptr_layer_number = 0
    ptr_file = ''
    if arguments.has_key('ptr_file') and arguments.has_key('ptr_layer_number'):
        ptr_file = arguments['ptr_file']
        ptr_layer_number = int(arguments['ptr_layer_number'])

    # check working dir to see whether it's resuming training
    resume_training = False
    if os.path.exists(wdir +
                      '/nnet.tmp') and os.path.exists(wdir +
Exemplo n.º 14
0
    ]
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg)
            exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    lstm_nnet_spec = arguments['lstm_nnet_spec']
    nnet_spec = arguments['nnet_spec']
    wdir = arguments['wdir']

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig()
    cfg.model_type = 'ATTEND'
    cfg.parse_config_attend(arguments, nnet_spec, lstm_nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2**30))
    log('> ... building the model')
    # setup model
    nn = ATTEND(numpy_rng=numpy_rng, theano_rng=theano_rng, cfg=cfg)

    # get the training, validation and testing function for the model
    log('> ... getting the finetuning functions')
    train_fn, valid_fn = nn.build_finetune_functions(
        (cfg.train_x, cfg.train_y), (cfg.valid_x, cfg.valid_y),
        batch_size=cfg.batch_size)
Exemplo n.º 15
0
    # check working dir to see whether it's resuming training
    resume_training = False
    if os.path.exists(wdir + '/nnet.tmp') and os.path.exists(wdir + '/training_state.tmp'):
        resume_training = True
        cfg.lrate = _file2lrate(wdir + '/training_state.tmp')
        log('> ... found nnet.tmp and training_state.tmp, now resume training from epoch ' + str(cfg.lrate.epoch))

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2 ** 30))
    log('> ... building the model')
    # setup model
    if cfg.do_dropout:
        dnn = DNN_Dropout(numpy_rng=numpy_rng, theano_rng = theano_rng, cfg = cfg)
    elif cfg.do_regression:
        dnn = DNN_REG(numpy_rng=numpy_rng, theano_rng = theano_rng, cfg = cfg)
        cfg.model_type = 'DNN_REG'
    else:
        dnn = DNN(numpy_rng=numpy_rng, theano_rng = theano_rng, cfg = cfg)
    # initialize model parameters
    # if not resuming training, initialized from the specified pre-training file
    # if resuming training, initialized from the tmp model file
    if (ptr_layer_number > 0) and (resume_training is False):
        _file2nnet(dnn.layers, set_layer_num = ptr_layer_number, filename = ptr_file)
    if resume_training:
        _file2nnet(dnn.layers, filename = wdir + '/nnet.tmp')

    # get the training, validation and testing function for the model
    log('> ... getting the finetuning functions')
    #TODO fix error in train_fn
    train_fn, valid_fn = dnn.build_finetune_functions(
                (cfg.train_x, cfg.train_y), (cfg.valid_x, cfg.valid_y),
Exemplo n.º 16
0
    arg_elements = [sys.argv[i] for i in range(1, len(sys.argv))]
    arguments = parse_arguments(arg_elements)
    required_arguments = ['train_data', 'valid_data', 'nnet_spec', 'lstm_nnet_spec', 'wdir']
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg); exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    nnet_spec = arguments['nnet_spec']
    lstm_nnet_spec = arguments['lstm_nnet_spec']
    wdir = arguments['wdir']

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig();cfg.model_type = 'LSTMV'
    cfg.parse_config_ldnn(arguments, nnet_spec, lstm_nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2 ** 30))
    log('> ... building the model')
    # setup model
    dnn = LSTMV(numpy_rng=numpy_rng, theano_rng = theano_rng, cfg = cfg)

    # get the training, validation and testing function for the model
    log('> ... getting the finetuning functions')
    train_fn, valid_fn = dnn.build_finetune_functions(
                (cfg.train_x, cfg.train_y), (cfg.valid_x, cfg.valid_y),
                batch_size=cfg.batch_size)
Exemplo n.º 17
0
    ]
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg)
            exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    conv_nnet_spec = arguments['conv_nnet_spec']
    nnet_spec = arguments['nnet_spec']
    wdir = arguments['wdir']

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig()
    cfg.model_type = 'CNN_LACEA'
    cfg.parse_config_cnn(arguments, '10:' + nnet_spec, conv_nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)

    # check working dir to see whether it's resuming training
    resume_training = False
    if os.path.exists(wdir + '/nnet.tmp_CNN_LACEA') and os.path.exists(
            wdir + '/training_state.tmp_CNN_LACEA'):
        resume_training = True
        cfg.lrate = _file2lrate(wdir + '/training_state.tmp_CNN_LACEA')
        log('> ... found nnet.tmp_CNN_LACEA and training_state.tmp_CNN_LACEA, now resume training from epoch '
            + str(cfg.lrate.epoch))

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2**30))
    log('> ... initializing the model')
Exemplo n.º 18
0
# check the arguments
arg_elements = [sys.argv[i] for i in range(1, len(sys.argv))]
arguments = parse_arguments(arg_elements)
required_arguments = ['train_data', 'valid_data', 'nnet_spec', 'wdir']
for arg in required_arguments:
    if arguments.has_key(arg) == False:
        print "Error: the argument %s has to be specified" % (arg); exit(1)

# mandatory arguments
train_data_spec = arguments['train_data']
valid_data_spec = arguments['valid_data']
nnet_spec = arguments['nnet_spec']
wdir = arguments['wdir']

# parse network configuration from arguments, and initialize data reading
cfg = NetworkConfig(); cfg.model_type = 'RNN'
cfg.parse_config_dnn(arguments, nnet_spec)
cfg.init_data_reading(train_data_spec, valid_data_spec)
print("training dataset is:", cfg.train_sets.pfile_path_list)
# parse pre-training options
# pre-training files and layer number (how many layers are set to the pre-training parameters)
ptr_layer_number = 0; ptr_file = ''
if arguments.has_key('ptr_file') and arguments.has_key('ptr_layer_number'):
    ptr_file = arguments['ptr_file']
    ptr_layer_number = int(arguments['ptr_layer_number'])

# check working dir to see whether it's resuming training
resume_training = False
if os.path.exists(wdir + '/nnet.tmp') and os.path.exists(wdir + '/training_state.tmp'):
    resume_training = True
    cfg.lrate = _file2lrate(wdir + '/training_state.tmp')
Exemplo n.º 19
0
    arguments = parse_arguments(arg_elements)
    required_arguments = ['train_data', 'valid_data', 'si_nnet_spec', 'si_conv_nnet_spec', 'wdir', 'adapt_nnet_spec', 'init_model']
    for arg in required_arguments:
        if (arg in arguments) == False:
            print("Error: the argument %s has to be specified" % (arg)); exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']; valid_data_spec = arguments['valid_data']
    si_nnet_spec = arguments['si_nnet_spec']
    si_conv_nnet_spec = arguments['si_conv_nnet_spec']
    adapt_nnet_spec = arguments['adapt_nnet_spec'];
    wdir = arguments['wdir']
    init_model_file = arguments['init_model']

    # parse network configuration from arguments, and initialize data reading
    cfg_si = NetworkConfig(); cfg_si.model_type = 'CNN'
    cfg_si.parse_config_cnn(arguments, '10:' + si_nnet_spec, si_conv_nnet_spec)
    cfg_si.init_data_reading(train_data_spec, valid_data_spec)

    # parse the structure of the i-vector network 
    cfg_adapt = NetworkConfig()
    net_split = adapt_nnet_spec.split(':')
    adapt_nnet_spec = ''
    for n in range(len(net_split) - 1):
        adapt_nnet_spec += net_split[n] + ':'
    cfg_adapt.parse_config_dnn(arguments, adapt_nnet_spec + '0')

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2 ** 30))
    log('> ... initializing the model')
    # setup up the model 
Exemplo n.º 20
0
    arg_elements = [sys.argv[i] for i in range(1, len(sys.argv))]
    arguments = parse_arguments(arg_elements)
    required_arguments = ['train_data', 'valid_data', 'nnet_spec', 'lstm_nnet_spec', 'wdir']
    for arg in required_arguments:
        if arguments.has_key(arg) == False:
            print "Error: the argument %s has to be specified" % (arg); exit(1)

    # mandatory arguments
    train_data_spec = arguments['train_data']
    valid_data_spec = arguments['valid_data']
    nnet_spec = arguments['nnet_spec']
    lstm_nnet_spec = arguments['lstm_nnet_spec']
    wdir = arguments['wdir']

    # parse network configuration from arguments, and initialize data reading
    cfg = NetworkConfig();cfg.model_type = 'ATTEND_LSTM'
    cfg.parse_config_attend(arguments, nnet_spec, lstm_nnet_spec)
    cfg.init_data_reading(train_data_spec, valid_data_spec)
    print 'Extra dim: '+str(cfg.extra_dim)

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2 ** 30))
    log('> ... building the model')
    # setup model
    dnn = PhaseATTEND_LSTM(numpy_rng=numpy_rng, theano_rng = theano_rng, cfg = cfg)

    # get the training, validation and testing function for the model
    log('> ... getting the finetuning functions')
    train_fn, valid_fn = dnn.build_finetune_functions(
                (cfg.train_x, cfg.train_y), (cfg.valid_x, cfg.valid_y), 
                (cfg.extra_train_x), (cfg.extra_valid_x),