-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdemo_faces.m
88 lines (77 loc) · 2.16 KB
/
demo_faces.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
function [F] = demo_viz()
% A simple demo of the warped mixture models
%
% David Duvenaud
% Tomoharu Iwata
%
% April 2012
addpath('util');
addpath('misc');
addpath('data');
addpath('gpml/cov');
addpath('gpml/util');
% Set the random seed, always the same for the datafolds.
seed = 2;
randn('state', seed);
rand('twister', seed);
%heads = {'spiral2'};
heads = {'umist_downsampled3'};
%close all;
num_fold = 1;
%num_fold = 10;
options = [];
options.isPlot = 50;
options.isMovie = 0;
%options.hmc_isPlot = 1;
options.hmc_isPlot = 0;
%options.isPlot = 20;
options.isGPLVMinit = 1;
for i = 1:numel(heads)
fn = sprintf('data/%s.mat',heads{i})
load(fn);
[N,observed_dimension] = size(X);
% Rescale dataset to [-1, 1].
X = X - repmat(min(X,[],1), N,1);
X = X./repmat(max(X,[],1), N,1);
X = X * 2 - 1;
assert(all(max(X, [], 1) <= 1))
assert(all(min(X, [], 1) >= -1))
if num_fold > 1
cv = cvpartition(N,'kfold',num_fold);
end
for k = 1:num_fold
if num_fold > 1
trainX = X(cv.training(k),:);
testX = X(cv.test(k),:);
trainy = y(cv.training(k));
testy = y(cv.test(k));
else
trainX = X;
testX = [];
trainy = y;
testy = [];
end
latent_dimensions = {2};
%options.num_iters = 4000;
%options.epslion = 0.01;
%options.Tau = 25;
options.num_iters = 500;
options.epsilon = 0.005;
options.Tau = 25;
num_components = 5;
options.prior_r = 1e-1;
options.prior_alpha = 1;
%Infinite Warped Mixture Model (DP&GPLVM)
options.isDP = 1;
options.isGP = 1;
for j = 1:numel(latent_dimensions)
[hist_post, hist_params, Ls, hist_assignments,F] = ...
gplvm_dpmix_integrate_infer(latent_dimensions{j},...
num_components,trainX,trainy,options);
%movie(F);
%movie2avi(F,'animation.avi');
ofn = 'results_faces/demo_faces2.mat';
save(ofn,'hist_post','hist_params','Ls','hist_assignments','F');
end
end
end