1function p = predict(Theta1, Theta2, X) 2%PREDICT Predict the label of an input given a trained neural network 3% p = PREDICT(Theta1, Theta2, X) outputs the predicted label of X given the 4% trained weights of a neural network (Theta1, Theta2) 5 6% Useful values 7m = size(X, 1); 8num_labels = size(Theta2, 1); 9 10% You need to return the following variables correctly 11p = zeros(size(X, 1), 1); 12 13h1 = sigmoid([ones(m, 1) X] * Theta1'); 14h2 = sigmoid([ones(m, 1) h1] * Theta2'); 15[dummy, p] = max(h2, [], 2); 16 17% ========================================================================= 18 19 20end 21 22