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. OpenGL ES 2.0 向量

    访问向量中的某个分量<向量名>.<分量名> 将一个向量看作位置时,可以使用x.y.z.w4个分量名,其分别代表X轴.Y轴.Z轴.向量的模. 将一个向量看作颜色时,可以使用r.g ...

  2. hdu 畅通工程续

    算法:多源最短路(floyd) 题意:有多个城镇,有些之间有通路,给你起点和终点,输出最短路径: Problem Description 某省自从实行了很多年的畅通工程计划后,终于修建了很多路.不过路 ...

  3. setTimeout与setInterval方法的区别

    setTimeout与setInterval方法的区别 setTimeout()用于设定在指定的时间之后执行对应的函数或代码.,在全局作用域下执行 setTimeout(code,time[,args ...

  4. 【笔记】shell下的主要工具

    shell 下有很多工具是非常好的辅助. 一.自我精进的途径 1.help / --help :简要的帮助说明: help 是针对 shell 内建功能的帮助, gnu工具一般为 "程序名 ...

  5. 转载收藏之用 - 微信公众平台开发教程(六):了解MessageHandler

    上一篇<Senparc.Weixin.MP SDK 微信公众平台开发教程(五):使用Senparc.Weixin.MP SDK>我们讲述了如何使用Senparc.Weixin.MP SDK ...

  6. Array.prototype.slice()的用法

    我们知道,Array.prototype.slice.call(arguments)能将具有length属性的对象转成数组,除了IE下的节点集合(因为ie下的dom对象是以com对象的形式实现的,js ...

  7. Extjs4.0.7 MVC Architecture异常

    uncaught exception: Ext.Loader is not enabled, so dependencies    cannot be resolved dynamically. Mi ...

  8. Linux下用Mytop监控MySQL资源

    https://www.centos.bz/2011/11/linux-install-perl-dbd-mysql/ http://blog.csdn.net/rital/article/detai ...

  9. ActionBar Fragment运用最佳实践

    ActionBar Fragment运用最佳实践  

  10. Square spiral

    Square spiral Nikola picks up a strange circuit board. All of its elements are connected in a spiral ...