How can I train my pylearn2 neural network on multiple target variables?

I have a functioning neural network pylearn2

that loads data from csv

and predicts a continuous target variable. How can I change it to predict several different target variables?

I am using Caggle African dataset .

And built this functioning mlp file:

!obj:pylearn2.train.Train {
dataset: &train !obj:pylearn2.datasets.csv_dataset.CSVDataset {
    path: 'C:\Users\POWELWE\Git\pylearn2\pylearn2\datasets\soil\training_CA.csv',
    task: 'regression',
    start: 0,
    stop: 1024,
    expect_headers: True,
    num_outputs: 1
},
model: !obj:pylearn2.models.mlp.MLP {
    layers : [
        !obj:pylearn2.models.mlp.RectifiedLinear {
            layer_name: 'h0',
            dim: 200,
            irange: .05,
            max_col_norm: 2.
        },
        !obj:pylearn2.models.mlp.RectifiedLinear {
            layer_name: 'h1',
            dim: 200,
            irange: .05,
            max_col_norm: 2.
        },
        !obj:pylearn2.models.mlp.LinearGaussian {
            init_bias: !obj:pylearn2.models.mlp.mean_of_targets {
                dataset: *train },
            init_beta: !obj:pylearn2.models.mlp.beta_from_targets {
                dataset: *train },
            min_beta: 1.,
            max_beta: 100.,
            beta_lr_scale: 1.,
            dim: 1,
            layer_name: 'y',
            irange: .005
        }
    ],
    nvis: 3594,
},
algorithm: !obj:pylearn2.training_algorithms.bgd.BGD {
    line_search_mode: 'exhaustive',
    batch_size: 1024,
    conjugate: 1,
    reset_conjugate: 0,
    reset_alpha: 0,
    updates_per_batch: 10,
    monitoring_dataset:
        {
            'train' : *train,
            'valid' : !obj:pylearn2.datasets.csv_dataset.CSVDataset {
                path: 'C:\Users\POWELWE\Git\pylearn2\pylearn2\datasets\soil\training_CA.csv',
                task: 'regression',
                start: 1024,
                stop: 1156,
                expect_headers: True,
            }
        },
    termination_criterion: !obj:pylearn2.termination_criteria.MonitorBased {
        channel_name: "valid_y_mse",
        prop_decrease: 0.,
        N: 100
    },
},
extensions: [
    !obj:pylearn2.train_extensions.best_params.MonitorBasedSaveBest {
         channel_name: 'valid_y_mse',
         save_path: "${PYLEARN2_TRAIN_FILE_FULL_STEM}_best.pkl"
    },
],
save_path: "mlp.pkl",
save_freq: 1

      

}

To predict a single target variable, I removed all of the target variables except from the dataset Ca

and moved them to the first column. When I run the following command in the console ipython

, it works for this single variable:

%run 'C:\Users\POWELWE\Git\pylearn2\pylearn2\scripts\train.py' mlp.yaml

      

I would like to include other 4 target variables ( P

, pH

, SOC

, Sand

), but do not know how I can set up my model for the training of these additional targets. I am guessing that I need to perform some manipulation with num_outputs

, dim

or nvis

, but have not succeeded in my attempts. This is a preliminary draft for one with many other target variables, so it is important that I train using a single net and not create a new net for each target variable.

+3


source to share


1 answer


To train a network that predicts the values ​​of several variables at the same time, you just need to tune the network to have multiple output neurons and feed it with the training data just like you know, but with multiple target values ​​at the same time. I haven't used pylearn ever - I prefer Caffe, nolearn (lasagne) or pybrain, each of these libraries can handle cases like this with ease.

An example pybrain implementation (the code was used in the kaggle BikeShare call):



http://pastebin.ru/tqpMTzIz

0


source







All Articles