日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > pytorch >内容正文

pytorch

重磅!深度学习圣经“花书”核心笔记、代码发布

發布時間:2025/3/15 pytorch 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 重磅!深度学习圣经“花书”核心笔记、代码发布 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

點擊上方“AI有道”,選擇“置頂”公眾號

重磅干貨,第一時間送達

《深度學習》,又名“花書”。該書由三位大佬 Ian Goodfellow、Yoshua Bengio 和 Aaron Courville 撰寫,是深度學習領域奠基性的經典教材,被譽為深度學習的“圣經”。

原書內容非常充實,接近 800 頁。這本書內容很深很全面,但起點稍微高了一些,對數學理論基礎知識要求的比較多。因此,讀完之后,及時進行高度概括和經驗總結是十分有幫助的。石頭君最近在 GitHub 上發現一個關于花書各章摘要的項目,內容非常精煉,除了筆記的同時,部分章節還配備代碼,值得推薦,我們一起來看一下。

該項目的名稱是:Deep-Learning-Book-Chapter-Summaries,作者是?Aman Dalmia 和?Ameya Godbole 兩位小哥。項目地址為:

https://github.com/dalmia/Deep-Learning-Book-Chapter-Summaries

主要內容

這份花書核心筆記主要涉及的章節包括:

  • ch02 線性代數

  • ch03 概率與信息理論

  • ch04 數值優化

  • ch07 深度學習正則化

  • ch08 深度模型中的優化

  • ch09 卷積網絡

  • ch11 實踐方法論

  • ch13 線性因子模型

筆記的形式是 .ipynb,便于在 Jupyter Notebook 上打開和觀看。例如,我們來看一下第二章線性代數的筆記。

可見,Jupyter 筆記不僅包含了知識點的總結,也有相關代碼。再來看第九章的卷積網絡部分,配備了一些完整的圖片處理代碼。

import numpy as np from scipy import signal from scipy import misc import matplotlib.pyplot as plt# %matplotlib inlineimg = misc.ascent() kernel = np.random.randn(5,5) # kernel = np.array([[0,-10,0,10,0],[-10,-30,0,30,10],[0,-10,0,10,0]])img = img.astype(np.float32)/255 orig_in = imgoffsetx = offsety = 20 shift_in = np.zeros(orig_in.shape) shift_in[offsetx:,offsety:] = img[:-offsetx,:-offsety]rot_in = misc.imrotate(img, 90) scale_in = misc.imresize(orig_in, 1.5)output1 = signal.convolve2d(orig_in, kernel, mode='same') output2 = signal.convolve2d(shift_in, kernel, mode='same') output3 = signal.convolve2d(rot_in, kernel, mode='same') output4 = signal.convolve2d(scale_in, kernel, mode='same')

fig, axes = plt.subplots(2, 4, figsize=(14, 7)) ax_orig = axes[0,0] ax_shift = axes[0,1] ax_rot = axes[0,2] ax_scale = axes[0,3]diff_orig = axes[1,0] diff_shift = axes[1,1] diff_rot = axes[1,2] diff_scale = axes[1,3]ax_orig.imshow(output1, cmap='gray') ax_orig.set_title('Original') ax_shift.imshow(output2, cmap='gray') ax_shift.set_title('Shifted') ax_rot.imshow(output3, cmap='gray') ax_rot.set_title('Rotated') ax_scale.imshow(output4, cmap='gray') ax_scale.set_title('Scaled')def shift(arr, offset):output = np.zeros(arr.shape)output[offset:, offset:] = arr[:-offset,:-offset]return outputdef rotate(arr, angle):return misc.imrotate(arr, angle)def resize(arr, scale):return misc.imresize(arr, scale)diff_orig.hist(np.ravel(output1),bins=100) diff_orig.set_title('Output histogram') diff_shift.hist(np.ravel(np.abs(output2-shift(output1, 20))),bins=100) diff_shift.set_title('Shift histogram difference') diff_rot.hist(np.ravel(np.abs(output3-rotate(output1, 10))),bins=100) diff_rot.set_title('Rotate histogram difference') diff_scale.hist(np.ravel(np.abs(output4-resize(output1, 1.5))),bins=100) diff_scale.set_title('Scale histogram difference')ax_orig.set_xticks([]) ax_shift.set_xticks([]) ax_rot.set_xticks([]) ax_scale.set_xticks([])ax_orig.set_yticks([]) ax_shift.set_yticks([]) ax_rot.set_yticks([]) ax_scale.set_yticks([])plt.tight_layout() # plt.show() plt.savefig('images/conv_equivariance.png')

對于池化層的代碼示例:

import numpy as np np.random.seed(101)from scipy import signal from scipy import misc import matplotlib.pyplot as plt %matplotlib inlineimg = misc.ascent() img = img.astype(np.float32)/255# The image is more interesting here orig_in = img[-200:,-300:-100] offsetx = offsety = 15 shift_in = img[-200-offsetx:-offsetx,-300-offsety:-100-offsety] kernel1 = np.random.randn(5,5) kernel2 = np.random.randn(5,5) kernel3 = np.random.randn(5,5)def sigmoid(arr):# Lazy implementation of sigmoid activationreturn 1./(1 + np.exp(-arr))def maxpool(arr, poolsize, stride):# Lazy looping implementation of maxpooloutput_shape = np.floor((np.array(arr.shape)-poolsize)/stride)+1output_shape = output_shape.astype(np.int32)output = np.zeros(output_shape)for x in range(output_shape[0]):for y in range(output_shape[1]):output[x,y] = np.max(arr[x*stride:x*stride+poolsize,y*stride:y*stride+poolsize])return outputoutput1_1 = signal.convolve2d(orig_in, kernel1, mode='valid') pool1_1 = maxpool(output1_1, 2, 2) actv1_1 = sigmoid(pool1_1) output1_2 = signal.convolve2d(actv1_1, kernel2, mode='valid') pool1_2 = maxpool(output1_2, 2, 2) actv1_2 = sigmoid(pool1_2) output1_3 = signal.convolve2d(actv1_2, kernel3, mode='valid') pool1_3 = maxpool(output1_3, 2, 2)output2_1 = signal.convolve2d(shift_in, kernel1, mode='valid') pool2_1 = maxpool(output2_1, 2, 2) actv2_1 = sigmoid(pool2_1) output2_2 = signal.convolve2d(actv2_1, kernel2, mode='valid') pool2_2 = maxpool(output2_2, 2, 2) actv2_2 = sigmoid(pool2_2) output2_3 = signal.convolve2d(actv2_2, kernel3, mode='valid') pool2_3 = maxpool(output2_3, 2, 2)fig, axes = plt.subplots(4, 3, figsize=(10, 10))k1, k2, k3 = axes[0,:] p1_1, p1_2, p1_3 = axes[1,:] p2_1, p2_2, p2_3 = axes[2,:] h1, h2, h3 = axes[3,:]k1.imshow(kernel1, cmap='gray') k1.set_title('kernel1') k2.imshow(kernel2, cmap='gray') k2.set_title('kernel2') k3.imshow(kernel3, cmap='gray') k3.set_title('kernel3') k1.set_xticks([]) k2.set_xticks([]) k3.set_xticks([]) k1.set_yticks([]) k2.set_yticks([]) k3.set_yticks([])p1_1.imshow(pool1_1, cmap='gray') p1_1.set_title('pool1_1') p1_2.imshow(pool1_2, cmap='gray') p1_2.set_title('pool1_2') p1_3.imshow(pool1_3, cmap='gray') p1_3.set_title('pool1_3') p1_1.set_xticks([]) p1_2.set_xticks([]) p1_3.set_xticks([]) p1_1.set_yticks([]) p1_2.set_yticks([]) p1_3.set_yticks([])p2_1.imshow(pool2_1, cmap='gray') p2_1.set_title('pool2_1') p2_2.imshow(pool2_2, cmap='gray') p2_2.set_title('pool2_2') p2_3.imshow(pool2_3, cmap='gray') p2_3.set_title('pool2_3') p2_1.set_xticks([]) p2_2.set_xticks([]) p2_3.set_xticks([]) p2_1.set_yticks([]) p2_2.set_yticks([]) p2_3.set_yticks([])h1.hist(np.ravel(np.abs(pool1_1-pool2_1)),bins=100) h1.set_title('Pool 1 diff') h2.hist(np.ravel(np.abs(pool1_2-pool2_2)),bins=100) h2.set_title('Pool 2 diff') h3.hist(np.ravel(np.abs(pool1_3-pool2_3)),bins=100) h3.set_title('Pool 3 diff')plt.tight_layout() # plt.show() plt.savefig('images/pool_invariance.png')

博客筆記

該項目的作者還在自己的個人網站上發布了花書的精煉筆記,地址為:

https://medium.com/inveterate-learner/tagged/deep-learning

附加資源

除了這份花書重點章節摘要之外,石頭君還推薦一份來自?Microsoft 計算機軟件工程師?Jeff Macaluso 總結的關于花書的經驗法則!

在線版閱讀地址:

https://jeffmacaluso.github.io/post/DeepLearningRulesOfThumb/

離線地址:

鏈接:

https://pan.baidu.com/s/1eLlJy3xB6Hs0w_Q7bO536g?

提取碼:7q1d

希望這份資源對你有所幫助~


【推薦閱讀】

干貨 | 公眾號歷史文章精選(附資源)

我的深度學習入門路線

我的機器學習入門路線圖

?歡迎加入

總結

以上是生活随笔為你收集整理的重磅!深度学习圣经“花书”核心笔记、代码发布的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。