一.使用循环: 1.1原始版逻辑回归: function g = sigmoid(z) g = zeros(size(z)); g = ./ ( + exp(-z)); end function [J, grad] = costFunction(theta, X, y) % Initialize some useful values m = length(y); % number of training examples J = ; grad = zeros(size(theta)); n =…
题目下载[传送门] 题目简述:识别图片中的数字,训练该模型,求参数θ. 出现了一个问题:虽然训练的模型能够有很好的预测准确率,但是使用minimize函数时候始终无法成功,无论设计的迭代次数有多大,如下图: import numpy as np import scipy.io as scio import matplotlib.pyplot as plt import scipy.optimize as op # X:5000*400 # Y:5000*10 # a1:5000*401(后500…
题目下载[传送门] 题目简述:识别图片中的数字,训练该模型,求参数θ. 第1步:读取数据文件: %% Setup the parameters you will use for this exercise input_layer_size = 400; % 20x20 Input Images of Digits hidden_layer_size = 25; % 25 hidden units num_labels = 10; % 10 labels, from 1 to 10 % (note…
参考:https://blog.csdn.net/u013733326/article/details/79847918 希望大家直接到上面的网址去查看代码,下面是本人的笔记 4.正则化 1)加载数据 仍是问题: 'c' argument has 1 elements, which is not acceptable for use with 'x' with s 解决——直接导入函数: import scipy.io as sio def load_2D_dataset(is_plot=Tru…
编程作业文件: machine-learning-ex2 1. Logistic Regression (逻辑回归) 有之前学生的数据,建立逻辑回归模型预测,根据两次考试结果预测一个学生是否有资格被大学录取. 载入学生数据,第1,2列分别为两次考试结果,第3列为录取情况. % Load Data % The first two columns contain the exam scores and the third column contains the label. data = load(…
课程视频地址:http://open.163.com/special/opencourse/machinelearning.html 课程主页:http://cs229.stanford.edu/ 更具体的资料链接:https://www.jianshu.com/p/0a6ef31ff77a 笔记参考自中文翻译版:https://github.com/Kivy-CN/Stanford-CS-229-CN 这一讲介绍了高斯判别分析以及朴素贝叶斯算法. Part IV 生成学习算法 到目前为止,我们…