about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/BNT/CPDs/@softmax_CPD/private/extract_params.m
blob: 486af06e725c3de3c4625f30a6b2cefdcb5e1118 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function [W, b] = extract_params(CPD)

% W(X,Y,Q), b(Y,Q)  where Y = ns(self), X = ns(cps), Q = prod(ns(dps))

glimsz = prod(CPD.sizes(CPD.dpndx));
ss = CPD.sizes(end);
cpsz       = sum(CPD.sizes(CPD.cpndx));
dp_as_cpsz = sum(CPD.sizes(CPD.dps_as_cps.ndx));
W = zeros(dp_as_cpsz + cpsz, ss, glimsz);
b = zeros(ss, glimsz);

for i=1:glimsz
  W(:,:,i) = CPD.glim{i}.w1;
  b(:,i) = CPD.glim{i}.b1(:);
end

W = myreshape(W, [dp_as_cpsz + cpsz ss CPD.sizes(CPD.dpndx)]);
b = myreshape(b, [ss CPD.sizes(CPD.dpndx)]);