mirror of
https://github.com/jlengrand/MachineLearningCoursera.git
synced 2026-03-10 08:31:20 +00:00
Week 4
Prediction using Neural Networks. Finishes Week 4!
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user