ufdl的新教程,从基础学起。第一节讲的是线性回归。主要目的是熟悉目标函数,计算梯度和优化。

按着教程写完代码后,总是编译出错,一查是mex的原因,实在不想整了。

这位博主用的是向量,比较简洁:http://blog.csdn.net/lingerlanlan/article/details/38377023

这位博主用的是循环,更好理解:http://www.cnblogs.com/william7neral/p/4448566.html

接下来是logistic regression和向量化,没什么好说的:http://blog.csdn.net/lingerlanlan/article/details/38390085

这节主要是完成liner_regression.m,包括计算目标函数f和梯度g,需要注意的是要分清变量是列向量还是行向量或是矩阵。

对matlab不太熟,所以我稍微注释了下

function [f,g] = linear_regression(theta, X,y)
%
% Arguments:
% theta - A vector containing the parameter values to optimize.列向量
% X - The examples stored in a matrix.
% X(i,j) is the i'th coordinate of the j'th example.
% y - The target value for each example. y(j) is the target for
% example j.行向量
%
%size(a,)求矩阵的行数 size(a,)求矩阵的列数,相当于length(a)
%size(a)同时求矩阵的行和列数
% m=size(X,);
m = size(X,);
n=size(X,); f=;
g=zeros(size(theta)); %
% TODO: Compute the linear regression objective by looping over the examples in X.
% Store the objective function value in 'f'.
%
% TODO: Compute the gradient of the objective with respect to theta by looping over
% the examples in X and adding up the gradient for each example. Store the
% computed gradient in 'g'. %%% YOUR CODE HERE %%%
h = theta' * X
f = (/)* (h-y)' * (h-y)
g = X * (h - y)'

UFLDL 教程学习笔记(一)的更多相关文章

  1. UFLDL 教程学习笔记(四)主成分分析

    UFLDL(Unsupervised Feature Learning and Deep Learning)Tutorial 是由 Stanford 大学的 Andrew Ng 教授及其团队编写的一套 ...

  2. UFLDL 教程学习笔记(三)自编码与稀疏性

    UFLDL(Unsupervised Feature Learning and Deep Learning)Tutorial 是由 Stanford 大学的 Andrew Ng 教授及其团队编写的一套 ...

  3. UFLDL 教程学习笔记(二)反向传导算法

    UFLDL(Unsupervised Feature Learning and Deep Learning)Tutorial 是由 Stanford 大学的 Andrew Ng 教授及其团队编写的一套 ...

  4. UFLDL 教程学习笔记(一)神经网络

    UFLDL(Unsupervised Feature Learning and Deep Learning)Tutorial 是由 Stanford 大学的 Andrew Ng 教授及其团队编写的一套 ...

  5. UFLDL 教程学习笔记(四)

    课程地址:http://ufldl.stanford.edu/tutorial/supervised/FeatureExtractionUsingConvolution/ 在之前的练习中,图片比较小, ...

  6. UFLDL 教程学习笔记(三)

    教程地址:http://ufldl.stanford.edu/tutorial/supervised/SoftmaxRegression/ logstic regression是二分类的问题,如果想要 ...

  7. UFLDL 教程学习笔记(六)主成分分析

    教程:http://ufldl.stanford.edu/tutorial/supervised/MultiLayerNeuralNetworks/ 以及这篇博文,写的很清楚:http://blog. ...

  8. UFLDL 教程学习笔记(二)

    课程链接:http://ufldl.stanford.edu/tutorial/supervised/LogisticRegression/ 这一节主要讲的是梯度的概念,在实验部分,比较之前的线性回归 ...

  9. UFLDL深度学习笔记 (一)反向传播与稀疏自编码

    UFLDL深度学习笔记 (一)基本知识与稀疏自编码 前言 近来正在系统研究一下深度学习,作为新入门者,为了更好地理解.交流,准备把学习过程总结记录下来.最开始的规划是先学习理论推导:然后学习一两种开源 ...

随机推荐

  1. helm 替换源的方法

    网上找了一个 helm 替换源的方法 挺好用的 mark 一下 helm repo remove stable helm repo add stable https://kubernetes.oss- ...

  2. Java关于Robot类的使用

    利用Robot类实现自动操作,实现效果是运行之后鼠标自动定位到整个屏幕坐标系的(635,454)位置,输入wangtianze package com.wtz.util; import java.aw ...

  3. python 实现二叉树的深度 & 广度优先遍历

    什么是树 在计算器科学中,树(英语:tree)是一种抽象数据类型(ADT)或是实现这种抽象数据类型的数据结构,用来模拟具有树状结构性质的数据集合.它是由n(n>0)个有限节点组成一个具有层次关系 ...

  4. CF10D LCIS

    题意翻译 求两个串的最长公共上升子序列. 题目描述 This problem differs from one which was on the online contest. The sequenc ...

  5. luogu1941 [NOIp2014]飞扬的小鸟 (dp)

    设f[i][j]为到达(i,j)这个位置的最小操作数 就有$f[i][j]=min\{f[i-1][j+Y[i-1]],f[i-1][j-X[i-1]*k]+k\}$ 然后考虑优化一下转移: 对于一系 ...

  6. bzoj4542: [Hnoi2016]大数(莫队)

    这题...离散化...$N$和$n$搞错了...查了$2h$...QAQ 考虑$s[l...r]$,可以由两个后缀$suf[l]-suf[r+1]$得到$s[l...r]$代表的数乘$10^k$得到的 ...

  7. 【洛谷P1119】灾后重建

    题目大意:给定一个 N 个顶点,M 条边的无向图,每个顶点有一个时间戳,且时间戳大小按照顶点下标大小依次递增,在给定时间 t 时,时间戳严格大于 t 的顶点不能被访问,现在有 Q 次询问,每次询问在给 ...

  8. HDU 6158 笛卡尔定理+韦达定理

    The Designer Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  9. vue npm start 自动打开网页

    打开config/index.js,设置: autoOpenBrowser: true,(默认是false,把false改为true即可)

  10. Lua程序设计(二)面向对象概念介绍

    ----------------------------------------------------------- Lua面向对象3 local smartMan = { name = " ...