I am trying to prepare a layered ANN using pylearn2 using pre-training with RBM. I modified a little script called run_deep_trainer , which is contained in the file pylearn2 \ pylearn2 \ scripts \ tutorials \ deep_trainer. I want a 4-layer network, where the first 3 are made with 500 GaussianBinaryRBM , and the last one with a mlp.Softmax layer.
Here's the script I created:
from pylearn2.models.rbm import GaussianBinaryRBM from pylearn2.models.softmax_regression import SoftmaxRegression from pylearn2.models.mlp import Softmax from pylearn2.training_algorithms.sgd import SGD from pylearn2.costs.autoencoder import MeanSquaredReconstructionError from pylearn2.termination_criteria import EpochCounter from pylearn2.datasets.dense_design_matrix import DenseDesignMatrix from pylearn2.energy_functions.rbm_energy import GRBM_Type_1 from pylearn2.blocks import StackedBlocks from pylearn2.datasets.transformer_dataset import TransformerDataset from pylearn2.costs.ebm_estimation import SMD from pylearn2.training_algorithms.sgd import MonitorBasedLRAdjuster from pylearn2.train import Train from optparse import OptionParser import numpy def get_dataset_timitConsSmall(): print('loading timitConsSmall dataset...') template = \ """!obj:pylearn2.datasets.timitConsSmall.timit.TIMIT { classes_number: 32, which_set: %s, }""" trainset = yaml_parse.load(template % "train")
He correctly performs the uncontrolled part of the preliminary training, but there is a mistake in the controlled part of the training:
Traceback (most recent call last): File "run_deep_trainer.py", line 404, in <module> main() File "run_deep_trainer.py", line 400, in main layer_trainers[-1].main_loop() File "/home/gortolan/pylearn2/pylearn2/train.py", line 141, in main_loop self.setup() File "/home/gortolan/pylearn2/pylearn2/train.py", line 121, in setup self.algorithm.setup(model=self.model, dataset=self.dataset) File "/home/gortolan/pylearn2/pylearn2/training_algorithms/sgd.py", line 243, in setup inf_params = [param for param in model.get_params() File "/home/gortolan/pylearn2/pylearn2/models/model.py", line 503, in get_params return list(self._params) AttributeError: 'Softmax' object has no attribute '_params'
If I use SoftmaxRegression (as a model) in the last layer, which means replacing the get_mlp_softmax() and get_layer_trainer_softmax() get_logistic_regressor() with get_logistic_regressor() and get_layer_trainer_logistic() , everything works fine.
It seems that the mlp.Softmax model mlp.Softmax not return parameters ( _params ) via the get_params() function.
Does anyone know how to fix this?