-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfeedForwardAutoencoder.m
More file actions
25 lines (15 loc) · 846 Bytes
/
feedForwardAutoencoder.m
File metadata and controls
25 lines (15 loc) · 846 Bytes
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
function [activation] = feedForwardAutoencoder(theta, hiddenSize, visibleSize, data)
% theta: trained weights from the autoencoder
% visibleSize: the number of input units (probably 64)
% hiddenSize: the number of hidden units (probably 25)
% data: Our matrix containing the training data as columns. So, data(:,i) is the i-th training example.
% We first convert theta to the (W1, W2, b1, b2) matrix/vector format, so that this
% follows the notation convention of the lecture notes.
W1 = reshape(theta(1:hiddenSize*visibleSize), hiddenSize, visibleSize);
b1 = theta(2*hiddenSize*visibleSize+1:2*hiddenSize*visibleSize+hiddenSize);
activation = sigmoid(W1*data + repmat(b1,1,size(data,2)));
%-------------------------------------------------------------------
end
function sigm = sigmoid(x)
sigm = 1 ./ (1 + exp(-x));
end