annotate reproduce_AES53rd/rerun_gradient_table3/gradient_table3.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 % cr_: training correct
wolffd@0 2 % cr : testing correct
wolffd@0 3 feature_file = 'rel_music_raw_features+simdata_ISMIR12';
wolffd@0 4 vars = whos('-file', feature_file);
wolffd@0 5 A = load(feature_file,vars(1).name,vars(2).name,vars(3).name,vars(4).name);
wolffd@0 6 raw_features = A.(vars(1).name);
wolffd@0 7 indices = A.(vars(2).name);
wolffd@0 8 tst_inx = A.(vars(3).name);
wolffd@0 9 trn_inx = A.(vars(4).name);
wolffd@0 10 %
wolffd@0 11 % figure(1); imagesc(raw_features);colorbar;
wolffd@0 12 mod = load('res_48');
wolffd@0 13 features = logistic(raw_features*mod.W_max{1} + repmat(mod.hB_max{1},size(raw_features,1),1));
wolffd@0 14 % figure(2); imagesc(features);colorbar;
wolffd@0 15
wolffd@0 16 num_case = size(trn_inx,1);
wolffd@0 17 [trnd_12 trnd_13] = subspace_distances(trn_inx,features,indices,1,1);
wolffd@0 18 [tstd_12 tstd_13] = subspace_distances(tst_inx,features,indices,1,1);
wolffd@0 19 cr_ = 0; % correct rate for training
wolffd@0 20 cr = 0; % correct rate for testing
wolffd@0 21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 22 %% CODE HERE %%
wolffd@0 23 %[Ws cr_] = gradient_ascent(trnd_12,trnd_13,0.1,0.1,0.00002); %eNum = 10
wolffd@0 24 [Ws cr_] = gradient_ascent(trnd_12,trnd_13,0.05,0.01,0.00002);
wolffd@0 25
wolffd@0 26 for i = 1:num_case
wolffd@0 27 cr = cr + sum((tstd_13{i}-tstd_12{i})*Ws{i}' > 0, 1)/size(tstd_12{i},1);
wolffd@0 28 end
wolffd@0 29 cr = cr/num_case;
wolffd@0 30 %% Check the result
wolffd@0 31 fprintf('Gradient RBM Test / Train Result=%f / %f\n',cr*100,cr_*100);
wolffd@0 32 %fprintf('Training=%f Testing=%f\n',cr_,cr);