kyunghyuncho / deepmat

Matlab Code for Restricted/Deep Boltzmann Machines and Autoencoders
http://users.ics.aalto.fi/kcho/
188 stars 95 forks source link

Output layer dimensions and Populating label matrices #3

Closed vktt closed 11 years ago

vktt commented 11 years ago

Hey,

Two more things.

  1. In example_mnist_mlp_rbm around line 25, you're hardcoding the dimensionality of the output layer. It can be done automatically using:

C=unique(X_labels); % Layers configuration layers = [size(X,2), 1000, 500, length(C)];

  1. Also, in a related way in mlp.m, the way you're populating the label matrices in not optimal (line 53 onwards). You can do the following:

disp('Now calculating the training label matrix') C=unique(targets); % new_targets = strcmp(repmat(targets,1,length(C)),repmat(C',length(targets),1)); new_targets = bsxfun(@eq,repmat(targets,1,length(C)),repmat(C',length(targets),1)); % clear C, label; disp('done!') size(new_targets)

Where either of bsxfun and strcmp are used depending on whether the labels are numeral or characters. It should be faster than what you're doing right now, and will work for character labels as well. The same also applies to populating label matrices for validation set.

Best, Vikrant.

kyunghyuncho commented 11 years ago

Thanks for the tip. I fixed mlp.m!