Prediction using Neural Networks.

Finishes Week 4!
This commit is contained in:
julien Lengrand-Lambert
2015-11-28 11:48:42 +01:00
parent fa364033c4
commit a4b3cd1403
3 changed files with 9 additions and 10 deletions

View File

@@ -39,10 +39,10 @@ m = size(X, 1);
rand_indices = randperm(m);
sel = X(rand_indices(1:100), :);
%displayData(sel);
displayData(sel);
fprintf('Program paused. Press enter to continue.\n');
%pause;
pause;
%% ============ Part 2: Vectorize Logistic Regression ============
% In this part of the exercise, you will reuse your logistic regression

View File

@@ -10,6 +10,9 @@ num_labels = size(Theta2, 1);
% You need to return the following variables correctly
p = zeros(size(X, 1), 1);
% Add ones to the X data matrix
X = [ones(m, 1) X];
% ====================== YOUR CODE HERE ======================
% Instructions: Complete the following code to make predictions using
% your learned neural network. You should set p to a
@@ -21,15 +24,11 @@ p = zeros(size(X, 1), 1);
% can use max(A, [], 2) to obtain the max for each row.
%
a2 = sigmoid(X * Theta1');
a2 = [ones(m, 1) a2];
a3 = sigmoid(a2 * Theta2');
[val, p] = max(a3, [], 2);
% =========================================================================
end