随笔分类 -  《动手学深度学习 Pytorch版》学习笔记

摘要:import collections import re from d2l import torch as d2l 解析文本的常见预处理步骤: 将文本作为字符串加载到内存中。 将字符串拆分为词元(如单词和字符)。 建立一个词表,将拆分的词元映射到数字索引。 将文本转换为数字索引序列,方便模型操作。 阅读全文
posted @ 2023-10-09 10:01 AncilunKiang 阅读(140) 评论(0) 推荐(0) 编辑
摘要:到目前为止,我们遇到的数据主要是表格数据和图像数据,并且所有样本都是独立同分布的。然而,大多数的数据并非如此。比如语句中的单词、视频中的帧以及音频信号,都是有顺序的。 简言之,如果说卷积神经网络可以有效地处理空间信息,那么本章的循环神经网络(recurrent neural network,RNN) 阅读全文
posted @ 2023-10-08 23:02 AncilunKiang 阅读(245) 评论(0) 推荐(0) 编辑
摘要:7.7.1 从 ResNet 到 DenseNet DenseNet 可以视为 ResNet 的逻辑扩展。 ResNet 将函数展开为 f(x)=x+g(x),即一个简单的线性项和一个复杂的非线性项。 若将 f 拓展成超过两部分,则 阅读全文
posted @ 2023-09-24 07:48 AncilunKiang 阅读(86) 评论(0) 推荐(0) 编辑
摘要:import torch from torch import nn from torch.nn import functional as F from d2l import torch as d2l 7.6.1 函数类 如果把模型看作一个函数,我们设计的更强大的模型则可以看作范围更大的函数。为了使函 阅读全文
posted @ 2023-09-23 08:24 AncilunKiang 阅读(381) 评论(0) 推荐(0) 编辑
摘要:7.5.1 训练深层网络 训练神经网络的实际问题: 数据预处理的方式会对最终结果产生巨大影响。 训练时,多层感知机的中间层变量可能具有更广的变化范围。 更深层的网络很复杂容易过拟合。 批量规范化对小批量的大小有要求,只有批量大小足够大时批量规范化才是有效的。 用 \(\boldsymbol{x}\i 阅读全文
posted @ 2023-09-22 18:51 AncilunKiang 阅读(132) 评论(0) 推荐(0) 编辑
摘要:import torch from torch import nn from torch.nn import functional as F from d2l import torch as d2l 7.4.1 Inception块 GoogLNet 中的基本卷积块叫做 Inception 块(大概 阅读全文
posted @ 2023-09-21 07:50 AncilunKiang 阅读(124) 评论(0) 推荐(0) 编辑
摘要:LeNet、AlexNet和VGG的设计模式都是先用卷积层与汇聚层提取特征,然后用全连接层对特征进行处理。 AlexNet和VGG对LeNet的改进主要在于扩大和加深这两个模块。网络中的网络(NiN)则是在每个像素的通道上分别使用多层感知机。 import torch from torch impo 阅读全文
posted @ 2023-09-20 08:45 AncilunKiang 阅读(125) 评论(0) 推荐(0) 编辑
摘要:import torch from torch import nn from d2l import torch as d2l 7.2.1 VGG 块 AlexNet 没有提供一个通用的模板来指导后续的研究人员设计新的网络,如今研究人员转向了块的角度思考问题。通过使用循环和子程序,可以很容易地在任何现 阅读全文
posted @ 2023-09-19 15:44 AncilunKiang 阅读(155) 评论(0) 推荐(0) 编辑
摘要:7.1.1 学习表征 深度卷积神经网络的突破出现在2012年。突破可归因于以下两个关键因素: 缺少的成分:数据 数据集紧缺的情况在 2010 年前后兴起的大数据浪潮中得到改善。ImageNet 挑战赛中,ImageNet数据集由斯坦福大学教授李飞飞小组的研究人员开发,利用谷歌图像搜索对分类图片进行预 阅读全文
posted @ 2023-09-18 08:23 AncilunKiang 阅读(104) 评论(0) 推荐(0) 编辑
摘要:import torch from torch import nn from d2l import torch as d2l 6.6.1 LeNet LetNet-5 由两个部分组成: - 卷积编码器:由两个卷积核组成。 - 全连接层稠密块:由三个全连接层组成。 模型结构如下流程图(每个卷积块由一个 阅读全文
posted @ 2023-09-17 20:58 AncilunKiang 阅读(169) 评论(0) 推荐(0) 编辑
摘要:import torch from torch import nn from d2l import torch as d2l 6.5.1 最大汇聚和平均汇聚 汇聚层和卷积层类似,区别在于汇聚层不带包含参数,汇聚操作是确定性的,通常计算汇聚窗口中所有元素的最大值或平均值,即最大汇聚和平均汇聚。 def 阅读全文
posted @ 2023-09-17 20:56 AncilunKiang 阅读(149) 评论(0) 推荐(0) 编辑
摘要:import torch from d2l import torch as d2l 6.4.1 多输入通道 简言之,多通道即为单通道之推广,各参数对上即可。 def corr2d_multi_in(X, K): # 先遍历“X”和“K”的第0个维度(通道维度),再把它们加在一起 return sum 阅读全文
posted @ 2023-09-17 20:55 AncilunKiang 阅读(171) 评论(0) 推荐(0) 编辑
摘要:6.3.1 填充 虽然我们用的卷积核较小,每次只会丢失几像素,但是如果应用多层连续的卷积层,累积的像素丢失就会很多。解决此问题的方法为填充。 填充后的输出形状将为 (nhkh+ph+1)×(nwkw+pw+1) import torch from torch imp 阅读全文
posted @ 2023-09-17 08:22 AncilunKiang 阅读(62) 评论(0) 推荐(0) 编辑
摘要:import torch from torch import nn from d2l import torch as d2l 6.2.1 互相关计算 X = torch.tensor([[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]]) K = t 阅读全文
posted @ 2023-09-16 09:13 AncilunKiang 阅读(108) 评论(0) 推荐(0) 编辑
摘要:6.1.1 不变性 平移不变性(translation invariance): 不管检测对象出现在图像中的哪个位置,神经网络的前面几层应该对相同的图像区域具有相似的反应,即为“平移不变性”。 局部性(locality): 神经网络的前面几层应该只探索输入图像中的局部区域,而不过度在意图像中相隔较远 阅读全文
posted @ 2023-09-15 16:34 AncilunKiang 阅读(169) 评论(0) 推荐(0) 编辑
摘要:5.6.1 计算设备 import torch from torch import nn torch.device('cpu'), torch.device('cuda:0') # cuda等价于cuda:0(只有一块显卡没法试别的块号) (device(type='cpu'), device(ty 阅读全文
posted @ 2023-09-14 07:57 AncilunKiang 阅读(91) 评论(0) 推荐(0) 编辑
摘要:5.5.1 加载和保存 import torch from torch import nn from torch.nn import functional as F x = torch.arange(4) torch.save(x, 'x-file') # 使用 save 保存 x2 = torch 阅读全文
posted @ 2023-09-14 07:56 AncilunKiang 阅读(46) 评论(0) 推荐(0) 编辑
摘要:5.4.1 不带参数的层 import torch import torch.nn.functional as F from torch import nn class CenteredLayer(nn.Module): def __init__(self): super().__init__() 阅读全文
posted @ 2023-09-13 19:47 AncilunKiang 阅读(102) 评论(0) 推荐(0) 编辑
摘要:import torch from torch import nn from d2l import torch as d2l 下面实例化的多层感知机的输入维度是未知的,因此框架尚未初始化任何参数,显示为“UninitializedParameter”。 net = nn.Sequential(nn. 阅读全文
posted @ 2023-09-12 14:55 AncilunKiang 阅读(334) 评论(0) 推荐(0) 编辑
摘要:import torch from torch import nn net = nn.Sequential(nn.Linear(4, 8), nn.ReLU(), nn.Linear(8, 1)) X = torch.rand(size=(2, 4)) net(X) tensor([[-0.3771 阅读全文
posted @ 2023-09-11 08:43 AncilunKiang 阅读(156) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示