forked from mudigonda/HMC_reducedflip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdEdX_student.m
33 lines (26 loc) · 996 Bytes
/
dEdX_student.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
% This software is made available under the Creative Commons
% Attribution-Noncommercial License.
% (http://creativecommons.org/licenses/by-nc/3.0/)
% copyright 2010 Jascha Sohl-Dickstein
function dE = dEdX_student( X, theta )%x, phi, nu )
X = [X;ones(1,size(X,2))];
% ff = phi*x;
% bb = 1./(1 + (ff).^2 / nu);
% dE = (nu+1)/2 * 2 * (phi' * (ff.*bb))/nu;
% product of student-t experts
ndims = size(X, 1);
nbatch = size(X, 2);
nexperts = prod(size(theta)) / (ndims+1);
W = reshape( theta, [nexperts, ndims+1] );
alpha = W(:,ndims+1);
W = W(:, 1:ndims);
ff = W * X;
ff2 = ff.^2;
off2 = 1 + ff2;
% lt = diag(alpha) * (ff./off2);
lt = bsxfun(@times, ff./off2, alpha);
dE = 2 * W' * lt;
dE = dE(1:end-1,:);
% E = E_POE( theta, X ); %%% temporary for diagnostic purposes
%figure(4);
%plot(sort(E));