-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmap_st_rbf.m
More file actions
49 lines (44 loc) · 1.55 KB
/
map_st_rbf.m
File metadata and controls
49 lines (44 loc) · 1.55 KB
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
function [f df] = map_st_rbf(omega,R)
% Mapping function for spatiotemporal radial basis function.
%
% This function assumes that that the parameters are defined over the entire real line, and then
% uses a logistic sigmoid transformation to map them into [0,1].
%
% USAGE: [f df] = map_st_rbf(omega,R)
%
% INPUTS:
% omega = [mu_s lambda_s mu_t lambda_t], where mu_s is a [1 x D-1] vector specifying the
% source center, and lambda_s is a scalar width parameter,
% mu_t is the temporal center and lambda_t its width
% R - [V x D] feature locations; the last dimension is time
%
% OUTPUTS:
% f - [1 x V] basis image
% df - [M x V] matrix of partial derivatives, where M is the number of parameters
%
% Sam Gershman, Jun 2011
omega = 1./(1+exp(-omega));
M = length(omega);
Ds = M-3; % number of spatial dimensions
mu_s = omega(1:Ds);
lambda_s = omega(Ds+1);
mu_t = omega(Ds+2);
lambda_t = omega(Ds+3);
g_s = bsxfun(@minus,mu_s,R(:,1:Ds));
h_s = sum(g_s.^2,2);
g_t = mu_t - R(:,Ds+1);
h_t = g_t.^2;
f = exp(-h_s/lambda_s - h_t/lambda_t)';
% derivatives
if nargout > 1
V = size(R,1);
df = zeros(M,V);
a = -2*f/lambda_s;
for Ds = 1:Ds
df(Ds,:) = a.*g_s(:,Ds)';
end
df(Ds+1,:) = f.*h_s'./(lambda_s^2);
df(Ds+2,:) = -2.*f'.*g_t./lambda_t;
df(Ds+3,:) = f.*h_t'./(lambda_t^2);
df = bsxfun(@plus,df,(omega.*(1-omega))');
end