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 dnn = CNN_SAT(numpy_rng=numpy_rng, theano_rng = theano_rng, cfg_si = cfg_si, cfg_adapt = cfg_adapt)
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') log('> ... found nnet.tmp and training_state.tmp, now resume training from epoch ' + str(cfg.lrate.epoch))
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') # construct the cnn architecture
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 dnn = CNN_SAT(numpy_rng=numpy_rng,