require 'torch'
require 'gnuplot' local nData =
local kWidth =
local xTrain = torch.linspace(-, , nData)
local yTrain = torch.pow(xTrain, )
print(xTrain)
print(yTrain)
local yTrain = yTrain + torch.mul(torch.randn(nData), 0.1)
print(yTrain) local function phi(x, y)
return torch.exp(-(/kWidth)*torch.sum(torch.pow(x-y,)))
end local Phi = torch.Tensor(nData, nData)
for i = , nData do
for j = , nData do
Phi[i][j] = phi(xTrain[{{i}}], xTrain[{{j}}])
end
end local regularizer = torch.mul(torch.eye(nData), 0.001)
local theta = torch.inverse((Phi:t()*Phi) + regularizer) * Phi:t() * yTrain local nTestData =
local xTest = torch.linspace(-, , nTestData) local PhiTest = torch.Tensor(nData, nTestData)
for i = , nData do
for j = , nTestData do
PhiTest[i][j] = phi(xTrain[{{i}}], xTest[{{j}}])
end
end local yPred = PhiTest:t() * theta gnuplot.plot({'Data', xTrain, yTrain, '+'}, {'Prediction', xTest, yPred, '-'})

Kernel Regression from Nando's Deep Learning lecture 5的更多相关文章

  1. Machine and Deep Learning with Python

    Machine and Deep Learning with Python Education Tutorials and courses Supervised learning superstiti ...

  2. (转) Learning Deep Learning with Keras

    Learning Deep Learning with Keras Piotr Migdał - blog Projects Articles Publications Resume About Ph ...

  3. 课程一(Neural Networks and Deep Learning),第二周(Basics of Neural Network programming)—— 3、Python Basics with numpy (optional)

    Python Basics with numpy (optional)Welcome to your first (Optional) programming exercise of the deep ...

  4. Theories of Deep Learning

    https://stats385.github.io/readings Lecture 1 – Deep Learning Challenge. Is There Theory? Readings D ...

  5. 深度学习 Deep Learning UFLDL 最新 Tutorial 学习笔记 1:Linear Regression

    1 前言 Andrew Ng的UFLDL在2014年9月底更新了. 对于開始研究Deep Learning的童鞋们来说这真的是极大的好消息! 新的Tutorial相比旧的Tutorial添加了Conv ...

  6. 转载 Deep learning:三(Multivariance Linear Regression练习)

    前言: 本文主要是来练习多变量线性回归问题(其实本文也就3个变量),参考资料见网页:http://openclassroom.stanford.edu/MainFolder/DocumentPage. ...

  7. Deep Learning Tutorial - Classifying MNIST digits using Logistic Regression

    Deep Learning Tutorial 由 Montreal大学的LISA实验室所作,基于Theano的深度学习材料.Theano是一个python库,使得写深度模型更容易些,也可以在GPU上训 ...

  8. 课程一(Neural Networks and Deep Learning),第二周(Basics of Neural Network programming)—— 4、Logistic Regression with a Neural Network mindset

    Logistic Regression with a Neural Network mindset Welcome to the first (required) programming exerci ...

  9. Kernel Methods for Deep Learning

    目录 引 主要内容 与深度学习的联系 实验 Cho Y, Saul L K. Kernel Methods for Deep Learning[C]. neural information proce ...

随机推荐

  1. Jquery去除从数据库中查询到的内容含有的p标签

    $("#topic_content").html($("#topic_content").text()); 如果这个数据是通过循环遍历出的数据,就需要下面这个代 ...

  2. (原)ubuntu16重装显卡驱动后,torch中的问题

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6030232.html 参考网址: https://github.com/torch/cutorch/i ...

  3. string 与char* char[]之间的转换

    1.首先必须了解,string可以被看成是以字符为元素的一种容器.字符构成序列(字符串).有时候在字符序列中进行遍历,标准的string类提供了STL容器接口.具有一些成员函数比如begin().en ...

  4. 用U盘烧写Uboot.bin到Nor Flash

    1.在开发板上面插上U盘 2.打到 NAND flash模式启动U-boot,输入以下命令打开usb设备. [u-boot@SMDK2440A]# usb reset //以重启的方式 或者用 [u- ...

  5. Asp.net mvc 3 file uploads using the fileapi

    Asp.net mvc 3 file uploads using the fileapi I was recently given the task of adding upload progress ...

  6. Android平台之不预览获取照相机预览数据帧及精确时间截

    在android平台上要获取预览数据帧是一件极其容易的事儿,但要获取每帧数据对应的时间截并不那么容易,网络上关于这方面的资料也比较少.之所以要获取时间截,是因为某些情况下需要加入精确时间轴才能解决问题 ...

  7. iOS: 消息通信中的Notification&KVO

    iOS: 消息通信中的Notification&KVO 在 iOS: MVC 中,我贴了张经典图: 其中的Model向Controller通信的Noification&KVO为何物呢? ...

  8. [Google Code Jam (Qualification Round 2014) ] B. Cookie Clicker Alpha

    Problem B. Cookie Clicker Alpha   Introduction Cookie Clicker is a Javascript game by Orteil, where ...

  9. Thread详解

    具体可参考:Java并发编程:Thread类的使用,这里对线程状态的转换及主要函数做一下补充. 一.线程状态转换图 注意: 阻塞状态是线程阻塞在synchronized代码块时的状态,而阻塞在Lock ...

  10. cygwin安装与使用

    cygwin安装很简单,下载运行setup.exe程序,一步一步就可以了. 具体安装细节参考:http://www.33lc.com/article/7276.html 安装完成后有如下问题: 在cm ...