整个项目的github:https://github.com/RobinLuoNanjing/MachineLearning_Ng_Python
里面可以下载进行代码实现的数据集
题目介绍:
In the previous part of this exercise, you implemented multi-class logistic regression to recognize handwritten digits. However, logistic regression cannot form more complex hypotheses as it is only a linear classifier.
In this part of the exercise, you will implement a neural network to recognize handwritten digits using the same training set as before. The neural network will be able to represent complex models that form non-linear hypotheses. For this week, you will be using parameters from a neural network that we have already trained. Your goal is to implement the feedforward propagation algorithm to use our weights for prediction. In next week’s ex- ercise, you will write the backpropagation algorithm for learning the neural network parameters.
翻译:
在之前的练习中,你实现了用多类逻辑回归去识别手写的数字。但是逻辑回归不能形成更复杂的假设。因为它仅仅是一个线性分类器。
在这节的练习里,你将会实现用一个神经网络来进行手写数字识别,数据集将会使用和上一节一样的数据。神经网络能够呈现更为复杂的非线性假设的模型。这一周,你们将会使用我们利用神经网络已经训练好的权重。你的目标就是实现前向传播算法进行预测。下周,你需要自己写一个反向传播算法来用神经网络进行学习。
题目解析:
就是把之前的利用逻辑回归算法里求出的theta,换成他们用神经网络求出的theta,然后进行一次预测。值得注意的是,已经训练好的theta有两组,一个是theta1,一个是theta2。
代码详细解释:
大部分代码基本上和上一节作业没有变化。
首先就是删掉了oneVsAll()函数,当然也顺便删掉了costFunction()和gradient()函数。我们不需要求theta,因为theta已经给出了。
1.然后直接看主函数。注意!!!!!!!!!!!!!!这里载入的是ex3data1.mat文件。也就是吴恩达作业中的数据,跟我上一节导入的数据不一样。上一节导入的数据是别人修改过的。区别是:ex3data1.mat文