楼主: Lisrelchen
2147 8

[ Lecture Notes]Understanding Machine Learning [推广有奖]

  • 0关注
  • 62粉丝

VIP

已卖:4194份资源

院士

67%

还不是VIP/贵宾

-

TA的文库  其他...

Bayesian NewOccidental

Spatial Data Analysis

东西方数据挖掘

威望
0
论坛币
50288 个
通用积分
83.6306
学术水平
253 点
热心指数
300 点
信用等级
208 点
经验
41518 点
帖子
3256
精华
14
在线时间
766 小时
注册时间
2006-5-4
最后登录
2022-11-6

楼主
Lisrelchen 发表于 2016-6-24 09:18:47 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

本帖隐藏的内容

http://www.cs.huji.ac.il/~shais/IML2014.html


本帖隐藏的内容

Shai Shalev-Shwartz.zip (9.94 MB)








二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Understand Learning machine earning Lecture

本帖被以下文库推荐

沙发
Lisrelchen 发表于 2016-6-24 09:20:34
  1. # -*- coding: utf-8 -*-
  2. """
  3. Simple demonstration of the Ellipsoid online learner on mnist
  4. @author: shais
  5. """

  6. import numpy as np
  7. import matplotlib.pyplot as plt

  8. dot = np.dot;
  9. sign = np.sign;
  10. outer = np.outer;
  11. zeros = np.zeros;
  12. eye = np.eye;
  13. sqrt = np.sqrt;

  14. #%%
  15. # read data

  16. dataDir = "/Users/shais/data/mnist/mnist/";

  17. X = np.loadtxt(dataDir + "train4vs7_data.txt.gz");
  18. Y = np.loadtxt(dataDir + "train4vs7_labels.txt.gz");
  19. d,n = X.shape;

  20. #%%

  21. # show some images
  22. plt.figure(1);
  23. for i in range (1,26):
  24.     ax = plt.subplot(5,5,i);
  25.     ax.axis('off');
  26.     if Y[i]>0:
  27.         ax.imshow(X[:,i].reshape(28,28),cmap="gray");
  28.     else:
  29.         ax.imshow(255-X[:,i].reshape(28,28),cmap="gray");

  30. plt.draw();

  31. #%%   

  32. # Initial Ellipsoid learner
  33. w = zeros((d,));
  34. A = eye(d);
  35. M = 0; # counts mistakes

  36. #%%

  37. # Loop Ellipsoid over data
  38. eta = d*d/(d*d-1.0);
  39. for t in range(0,n):
  40.     yhat = sign(dot(w,X[:,t]));
  41.     if Y[t] != yhat:
  42.         M = M+1;
  43.         Ax = dot(A , X[:,t]);
  44.         xAx = dot(X[:,t] , Ax);
  45.         w = w + Y[t]/((d+1)*sqrt(xAx)) * Ax;
  46.         A = eta*( A - (2.0/((d+1.0)*xAx)) * outer(Ax,Ax) );

  47. #%%

  48. # show the mask learnt by ellipsoid

  49. plt.figure(2);
  50. ax1 = plt.subplot(1,2,1);
  51. ax1.axis('off'); # no need for axis marks
  52. ax2 = plt.subplot(1,2,2);
  53. ax2.axis('off'); # no need for axis marks
  54. ax1.imshow(w.reshape(28,28),cmap="gray");
  55. tmp = 1/(1+np.exp(-10*w/w.max()));
  56. ax2.imshow(tmp.reshape(28,28),cmap="gray");
  57. plt.draw();
  58. #%%
复制代码

藤椅
shgby 发表于 2016-6-24 09:41:59
Understanding Machine Learning

板凳
hjtoh 发表于 2016-6-24 09:42:46 来自手机
Lisrelchen 发表于 2016-6-24 09:18
**** 本内容被作者隐藏 ****
**** 本内容被作者隐藏 ****
谢谢分享

报纸
lionli 发表于 2016-6-24 10:07:24
thanks for learning

地板
fengyg 企业认证  发表于 2016-6-24 12:25:28
kankan

7
econ8008 发表于 2016-6-25 08:44:18
谢谢分享

8
sqy 发表于 2016-6-25 08:55:32
顶!!!!!

9
红狐1号 发表于 2018-12-6 23:51:06
上课地方就是谢谢

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-23 08:08