Files
test/machine_learning/course2/assignment4/configuration_goodness.m

10 lines
672 B
Matlab

function G = configuration_goodness(rbm_w, visible_state, hidden_state)
% <rbm_w> is a matrix of size <number of hidden units> by <number of visible units>
% <visible_state> is a binary matrix of size <number of visible units> by <number of configurations that we're handling in parallel>.
% <hidden_state> is a binary matrix of size <number of hidden units> by <number of configurations that we're handling in parallel>.
% This returns a scalar: the mean over cases of the goodness (negative energy) of the described configurations.
cases = size( visible_state, 2 );
sisj_wij = rbm_w .* (hidden_state * visible_state');
G = sum( sum( sisj_wij )) / cases;
end