function p = predict(Theta1, Theta2, X)
%PREDICT Predict the label of an input given a trained neural network
% p = PREDICT(Theta1, Theta2, X) outputs the predicted label of X given the
% trained weights of a neural network (Theta1, Theta2)
% Useful values
m = size(X, 1);
num_labels = size(Theta2, 1);
% You need to return the following variables correctly
p = zeros(size(X, 1), 1);
% ====================== YOUR CODE HERE ======================
% Instructions: Complete the following code to make predictions using
% your learned neural network. You should set p to a
% vector containing labels between 1 to num_labels.
%
% Hint: The max function might come in useful. In particular, the max
% function can also return the i
吴恩达的机器学习编程作业9:predict 神经网络预测结果
最新推荐文章于 2022-10-29 11:55:24 发布
这段代码展示了如何利用训练好的神经网络权重Theta1和Theta2进行预测。通过添加偏置项,计算隐藏层和输出层的激活值,然后应用sigmoid函数,最终使用max函数找出最大概率对应的类别标签。
摘要由CSDN通过智能技术生成