Exemplo n.º 1
0
            pool_size, pnorm_order = parse_two_integers(arguments['activation'])

    # deal with dropout
    do_dropout = False
    dropout_factor = [0.0]
    input_dropout_factor = 0.0
    if arguments.has_key('dropout_factor'):
        do_dropout = True
        if arguments.has_key('input_dropout_factor'):
            input_dropout_factor = float(arguments['input_dropout_factor'])
        dropout_factor = []
        factors = arguments['dropout_factor'].split(',')
        for n in xrange(len(factors)):
            dropout_factor.append(float(factors[n]))

    train_dataset, train_dataset_args = read_data_args(train_data_spec)
    valid_dataset, valid_dataset_args = read_data_args(valid_data_spec)
    train_sets, train_xy, train_x, train_y = read_dataset(train_dataset, train_dataset_args)
    valid_sets, valid_xy, valid_x, valid_y = read_dataset(valid_dataset, valid_dataset_args)

    numpy_rng = numpy.random.RandomState(89677)
    theano_rng = RandomStreams(numpy_rng.randint(2 ** 30))
    log('> ... building the model')
    if do_dropout:
        dnn = DNN_Dropout(numpy_rng=numpy_rng, theano_rng = theano_rng, n_ins=n_ins,
              hidden_layers_sizes=hidden_layers_sizes, n_outs=n_outs,
              activation = activation, dropout_factor = dropout_factor, input_dropout_factor = input_dropout_factor,
              do_maxout = do_maxout, pool_size = pool_size,
              max_col_norm = max_col_norm, l1_reg = l1_reg, l2_reg = l2_reg)
    else:
        dnn = DNN(numpy_rng=numpy_rng, theano_rng = theano_rng, n_ins=n_ins,
Exemplo n.º 2
0
        epochs = int(arguments['epoch_number'])

    # momentum; more complicated than dnn 
    initial_momentum = 0.5     # initial momentum 
    final_momentum = 0.9       # final momentum
    initial_momentum_epoch = 5 # for how many epochs do we use initial_momentum
    if arguments.has_key('momentum'):
        momentum_elements = arguments['momentum'].split(':')
        if len(momentum_elements) != 3:
            print "Error: momentum string should have 3 values, e.g., 0.5:0.9:5"
            exit(1)
        initial_momentum = float(momentum_elements[0])
        final_momentum = float(momentum_elements[1])
        initial_momentum_epoch = int(momentum_elements[2])

    dataset, dataset_args = read_data_args(train_data_spec)

    nnet_layers = nnet_spec.split(":")
    n_ins = int(nnet_layers[0])
    hidden_layers_sizes = []
    for i in range(1, len(nnet_layers)-1):
        hidden_layers_sizes.append(int(nnet_layers[i]))
    n_outs = int(nnet_layers[-1])

    ptr_layer_number = len(hidden_layers_sizes)
    if arguments.has_key('ptr_layer_number'):
        ptr_layer_number = int(arguments['ptr_layer_number'])

    first_layer_gb = True
    if arguments.has_key('first_layer_type'):
        if arguments['first_layer_type'] == 'bb':