《从深度学习基础到车道线模型训练与部署》学习(二)

1.transforms.Compose的含义与原理

transforms.Compose,transforms.ToTensor(),transforms.Normalize()的含义与原理_GIS_11的博客-CSDN博客transforms.Compose,transforms.ToTensor(),transforms.Normalize()的含义与原理1.问题描述问题来源于pytorch神经网络的示例代码:transform = transforms.Compose( [transforms.ToTensor(), transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])作用主要是读取CIFAR10数https://blog.csdn.net/qq_41795143/article/details/113761473

2.Python图像库PIL

Python图像库PIL(Python Image Library)是python的第三方图像处理库,但是由于其强大的功能与众多的使用人数,几乎已经被认为是python官方图像处理库了。其官方主页为:PIL。 PIL历史悠久,原来是只支持python2.x的版本的,后来出现了移植到python3的库pillow,pillow号称是friendly fork for PIL,其功能和PIL差不多,但是支持python3。本文主要介绍PIL那些最常用的特性与用法,主要参考自:http://www.effbot.org/imagingbook
Python图像库PIL的类Image及其方法介绍_leemboy的博客-CSDN博客_pilPython图像库PIL(Python Image Library)是python的第三方图像处理库,但是由于其强大的功能与众多的使用人数,几乎已经被认为是python官方图像处理库了。其官方主页为:PIL。 PIL历史悠久,原来是只支持python2.x的版本的,后来出现了移植到python3的库pillow,pillow号称是friendly fork for PIL,其功能和PIL差不多,但...https://blog.csdn.net/leemboy/article/details/83792729

3. nn.Flatten()——展平层

pytorch自学笔记——多层感知机_还是那个狗蛋的博客-CSDN博客import torchfrom torch import nnfrom d2l import torch as d2l#接一下数据集batch_size = 256train_iter, test_iter = d2l.load_data_fashion_mnist(batch_size)#定义模型net = nn.Sequential(nn.Flatten(), nn.Linear(784, 256), nn.ReLU(), nn.Linear.https://blog.csdn.net/weixin_50774105/article/details/117754596Pytorch:torch.flatten()与torch.nn.Flatten()_Super_user_and_woner的博客-CSDN博客_nn.flattentorch.flatten(x)等于torch.flatten(x,0)默认将张量拉成一维的向量,也就是说从第一维开始平坦化,torch.flatten(x,1)代表从第二维开始平坦化。import torchx=torch.randn(2,4,2)print(x)z=torch.flatten(x)print(z)w=torch.flatten(x,1)print(w)输出为:tensor([[[-0.9814, 0.8251], [ 0.8197, -1.https://blog.csdn.net/Super_user_and_woner/article/details/120782656

4.如何在PyTorch中初始化权重

net = nn.Sequential(nn.Flatten(),
                    nn.Linear(784, 256),
                    nn.ReLU(),
                    nn.Linear(256, 10))

def init_weights(m):
    if type(m) == nn.Linear:
        nn.init.normal_(m.weight, std=0.01)

net.apply(init_weights);

如何在PyTorch中初始化权重?icon-default.png?t=LBL2https://qastack.cn/programming/49433936/how-to-initialize-weights-in-pytorch

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值