11 2022 档案
13.6 目标检测数据集
摘要:13.6.0 头文件 import os import pandas as pd import torch import torchvision from d2l import torch as d2l from matplotlib import pyplot as plt 13.6.1 下载ba 阅读全文
posted @ 2022-11-27 15:26 yc-limitless 阅读(433) 评论(0) 推荐(0)
13.2 微调
摘要:13.2.0 头文件 # 通过微调在ImageNet数据集上预训练得到的ResNet模型,得到新的微调模型 # 利用新的微调模型在一个小型数据集上识别图像中是否包含热狗 import os import torch import torchvision from torch import nn fr 阅读全文
posted @ 2022-11-27 13:25 yc-limitless 阅读(169) 评论(0) 推荐(0)
12.6 多GPU训练网络模型的简洁实现
摘要:12.6.0 头文件 import torch from torch import nn from d2l import torch as d2l 12.6.1 定义ResNet-18网络模型 # 定义ResNet-18网络模型 def resnet18(num_classes, in_channe 阅读全文
posted @ 2022-11-26 23:41 yc-limitless 阅读(164) 评论(0) 推荐(0)
12.5 多GPU训练的手动实现
摘要:12.5.0 头文件 import torch from torch import nn from torch.nn import functional as F from d2l import torch as d2l 12.5.1 创建网络模型并初始化模型参数 # 初始化模型参数 scale = 阅读全文
posted @ 2022-11-26 21:40 yc-limitless 阅读(152) 评论(0) 推荐(0)
13.1图像增广
摘要:13.1.0 头文件 import torch import torchvision from torch import nn from d2l import torch as d2l from matplotlib import pyplot as plt d2l.set_figsize() 13 阅读全文
posted @ 2022-11-24 16:26 yc-limitless 阅读(106) 评论(0) 推荐(0)
13.3 目标检测和边界框
摘要:13.3.0头文件 import torch from d2l import torch as d2l from matplotlib import pyplot as plt d2l.set_figsize() 13.3.1 边界框坐标转换 # 把框框的(左上(x,y),右下(x,y))坐标转换为 阅读全文
posted @ 2022-11-24 14:23 yc-limitless 阅读(156) 评论(0) 推荐(0)
7.6 批量归一化层
摘要:7.6.0 头文件 import torch from torch import nn from d2l import torch as d2l import pandas as pd import numpy as np from matplotlib import pyplot as plt t 阅读全文
posted @ 2022-11-24 10:27 yc-limitless 阅读(143) 评论(0) 推荐(0)
用从远程库克隆的方式创建远程库和本地仓库
摘要:(1)登录GitHub,点击主页左上角的new创建一个名字为gitskills的远程仓库,并且勾选上Initialize this repository with a README选项,这样GitHub会自动创建一个README.md文件 (2)在本地利用下面的命令将远程仓库克隆到本地 $ git 阅读全文
posted @ 2022-11-23 10:39 yc-limitless 阅读(35) 评论(0) 推荐(0)
在Github创建远程仓库,并将本地仓库与远程仓库关联
摘要:1、在Github创建远程仓库 (1)登录GitHub (2)在主页的“Start a new repository"界面输入远程仓库名称,选择public后,点击”Create a new repository“按钮,创建一个远程仓库 2、将本地仓库与远程仓库关联 (1)在本地的learngit仓 阅读全文
posted @ 2022-11-23 09:58 yc-limitless 阅读(832) 评论(0) 推荐(0)
把电脑的key添加到GitHub
摘要:1、注册Github账号 2、在用户主目录下输入如下命令创建SSH Key $ ssh-keygen -t rsa -C "youremail@example.com" 把 youremail@example.com 替换成自己的邮箱,然后一路回车就可以了,会在用户主目录下生成一个 .ssh 目录, 阅读全文
posted @ 2022-11-23 09:28 yc-limitless 阅读(177) 评论(0) 推荐(0)
删除文件
摘要:首先创建一个test.txt文件并提交分支中。 $ touch test.txt $ git add test.txt $ git commit -m "add test.txt" 一般删除文件时会使用rm指令来删除文件 $ rm test.txt 这是有两种情况: (1)就是要删除这个文件,并更新 阅读全文
posted @ 2022-11-20 00:40 yc-limitless
撤销修改
摘要:1、撤销在工作区的修改 分为两种情况: (1)如果readme.txt修改后还没有放到暂存区,就撤销回和分支中相同的状态 (2)如果readme.txt修改后被放到了暂存区,然后又在工作区进行了修改,就撤销回和暂存区相同的状态 例子: 修改readme.txt文件为: Git is a distri 阅读全文
posted @ 2022-11-20 00:25 yc-limitless
管理修改
摘要:一个小实验 1、修改readme.txt文件 Git is a distributed version control system. Git is free software distributed under the GPL. Git has a mutable index called sta 阅读全文
posted @ 2022-11-19 23:59 yc-limitless
工作区、暂存区、master分支
摘要:1、工作区 工作区就是值每个目录,比如learngit就是一个工作区,对文件的直接修改就是在工作区修改文件。 2、版本库 版本库就是.git文件夹,版本库中存放有暂存区和master分支。 工作区、版本库、暂存区、master分支之间的关系如下图所示: 3、暂存区 git add 命令就是将修改添加 阅读全文
posted @ 2022-11-19 23:41 yc-limitless
版本回退
摘要:1、再次修改readme.txt文件,并把修改提交至版本库,修改内容为: Git is a distributed version control system. Git is free software distributed under the GPL. 提交命令: $ git add read 阅读全文
posted @ 2022-11-19 23:12 yc-limitless
修改文件并向仓库提交修改
摘要:1、修改文件 首先将readme.txt文件修改为: Git is a distributed version control system. Git is free software. 输入 git status 命令查看仓库中是否有文件被修改: 该命令输出的结果说明,readme.txt文件被修 阅读全文
posted @ 2022-11-19 21:47 yc-limitless
创建版本库
摘要:1、什么是版本库? 可以简单地理解为一个目录,这个吗,目录中的所有文件都可以被Git管理起来 2、在创建一个版本库 首先用下面的命令创建并进入一个空文件夹 $ mkdir learngit $ cd learngit $ pwd /home/yincong/learngit 然后用 git init 阅读全文
posted @ 2022-11-19 21:23 yc-limitless
安装Git
摘要:1、在Linux下安装Git 在命令行中输入 git ,如果显示内容如下,说明还没有安装git。 使用下面的命令安装Git: sudo apt-get install git 2、在Windows上安装Git: 在Git官网https://git-scm.com/downloads下载Git安装程序 阅读全文
posted @ 2022-11-19 20:57 yc-limitless
一些好看的电影电视剧
摘要:《他人即地狱》 观看地址 《弱小英雄》 观看地址 《僵尸校园》 观看地址 《你好妈妈,再见》 观看地址 《模范出租车》 观看地址 《365:逆转命运的1年》 观看地址 《我是大哥大》 观看地址 《我是大哥大 电影版》 观看地址 《雷神4 爱与雷霆》 观看地址 《我是遗物整理师》 观看地址 《电话》 阅读全文
posted @ 2022-11-19 09:53 yc-limitless 阅读(355) 评论(0) 推荐(0)
7.5 GoogLeNet
摘要:7.5.0 头文件 import torch from torch import nn from torch.nn import functional as F from d2l import torch as d2l from matplotlib import pyplot as plt 7.5 阅读全文
posted @ 2022-11-17 22:45 yc-limitless
7.4 NIN
摘要:7.4.0 头文件 import torch from torch import nn from d2l import torch as d2l from matplotlib import pyplot as plt 7.4.1 NiN网络模型 # 创建一个NiN块,NiN块包含三个卷积层,第一个 阅读全文
posted @ 2022-11-17 19:41 yc-limitless
7.3 VGG
摘要:7.3.0 头文件 import torch from torch import nn from d2l import torch as d2l from matplotlib import pyplot as plt 7.3.1 定义VGG11网络模型 # num_convs:该VGG块中包含的卷 阅读全文
posted @ 2022-11-17 16:36 yc-limitless
7.2 AlexNet
摘要:7.2.0 头文件 import torch from torch import nn from d2l import torch as d2l from matplotlib import pyplot as plt 7.2.1 定义AlexNet网络模型 # 定义AlexNet网络模型 net 阅读全文
posted @ 2022-11-10 16:49 yc-limitless
7.1 LeNet
摘要:对卷积网络的形象理解: 卷积网络在形式上类似于人民代表大会制度,卷积核相当于候选人,多个卷积核就相当于多个候选人,图像中不同的特征会激活不同的卷积核,池化层起着类似于合票的作用,代表着一个区域的得分,全连接层相当于对每个区域选出来的代表进行最终的投票 7.1.0 头文件 import torch f 阅读全文
posted @ 2022-11-09 21:28 yc-limitless
6.5 池化层
摘要:6.5.0 头文件 import torch from torch import nn from d2l import torch as d2l 6.5.1 自定义的图像池化操作 # X:待池化图像 pool_size池化尺寸 mode池化模式 # 对图像在每个通道上分别进行最大池化或平均池化,最后 阅读全文
posted @ 2022-11-09 17:01 yc-limitless
6.4 多输入通道与多输出通道
摘要:6.4.0 头文件 import torch from d2l import torch as d2l 6.4.1 多输入通道单输出通道卷积运算 # 定义多输入通道单输出通道卷积运算:将输入图像的第一个通道与卷积核第一个通道进行卷积运算,将输入图像的第二个通道与卷积核第二个通道进行卷积运算,依此类推 阅读全文
posted @ 2022-11-09 16:28 yc-limitless
6.3 填充和步幅
摘要:import torch from torch import nn # conv2d:卷积模型 # X:待卷积的图像(行数,列数) # 定义一个进行卷积操作的函数,返回卷积操作后的图像(不包含批量大小和通道数) def comp_conv2d(conv2d, X): # 把X维度扩充为(批量大小,通 阅读全文
posted @ 2022-11-09 15:30 yc-limitless
6.2 图像卷积
摘要:6.2.0 头文件 import torch from torch import nn from d2l import torch as d2l 6.2.1 图像与卷积核的卷积操作 # X:待卷积的图像 # K:卷积核 # 将图像X与卷积核K进行卷积操作,返回卷积的结果(无填充) def corr2 阅读全文
posted @ 2022-11-08 23:45 yc-limitless
5.4 张量和模型参数的导入与导出
摘要:5.4.0 头文件 import torch from torch import nn from torch.nn import functional as F 5.4.1 把张量保存在本地,从本地导入张量 # 定义一个张量 x = torch.arange(4) # 将张量x保存在本地x-file 阅读全文
posted @ 2022-11-08 17:01 yc-limitless
5.3 层
摘要:5.3.0 头文件 import torch import torch.nn.functional as F from torch import nn 5.3.1 定义不带参数的层 # 定义不带参数的层 class CenteredLayer(nn.Module): def __init__(sel 阅读全文
posted @ 2022-11-08 15:22 yc-limitless
5.2 模型参数
摘要:5.2.0 头文件 import torch from torch import nn 5.2.1创建一个网络模型 # 通过实例化nn.Sequential来创建一个网络模型,模型包括一个具有8个隐藏单元带有relu激活函数的全连接隐藏层,具有1个输出单元不带激活函数的全连接输出层 net = nn 阅读全文
posted @ 2022-11-08 14:55 yc-limitless
5.1 块
摘要:5.1.0 头文件 import torch from torch import nn from torch.nn import functional as F 5.1.1 通过实例化nn.Sequential来构建网络模型 # 通过实例化nn.Sequential来构建网络模型,该网络模型包含一个 阅读全文
posted @ 2022-11-08 10:28 yc-limitless
4.10 预测房价实战
摘要:4.10.0 头文件 import hashlib import os import tarfile import zipfile import requests import numpy as np import pandas as pd import torch from torch impor 阅读全文
posted @ 2022-11-07 20:43 yc-limitless
4.6 暂退法(dropout)框架实现
摘要:4.6.0 头文件 import torch from torch import nn from d2l import torch as d2l from matplotlib import pyplot as plt 4.6.1 定义损失函数 # 定义交叉熵损失函数 loss = nn.Cross 阅读全文
posted @ 2022-11-06 10:26 yc-limitless
4.6 暂退法(dropout)从零实现
摘要:4.6.0 头文件 import torch from torch import nn from d2l import torch as d2l from matplotlib import pyplot as plt 4.6.1 定义dropout层 def dropout_layer(X, dr 阅读全文
posted @ 2022-11-05 22:09 yc-limitless
4.5 L2正则化框架实现
摘要:4.5.0 头文件 import torch from torch import nn from d2l import torch as d2l from matplotlib import pyplot as plt 4.5.1 制作数据集 # 训练集样本数、测试集样本数、样本维度、批量大小 n_ 阅读全文
posted @ 2022-11-05 19:32 yc-limitless
4.5 L2正则化从零实现
摘要:4.5.0 头文件 import torch from torch import nn from d2l import torch as d2l from matplotlib import pyplot as plt 4.5.1 初始化模型权重和偏移量 # 训练集样本数、测试集样本数、样本维度、批 阅读全文
posted @ 2022-11-05 17:45 yc-limitless
5.6 GPU与张量,GPU与网络模型
摘要:5.6.0 头文件 import torch from torch import nn 5.6.1获取GPU # 获取指定GPU,如果指定编号的GPU存在,则返回gpu(i),否则返回cpu def try_gpu(i=0): if torch.cuda.device_count() >= i + 阅读全文
posted @ 2022-11-04 23:54 yc-limitless
4.4 欠拟合与过拟合
摘要:4.4.0 头文件 import math import numpy as np import torch from torch import nn from d2l import torch as d2l from matplotlib import pyplot as plt 4.4.1利用三阶 阅读全文
posted @ 2022-11-04 23:33 yc-limitless
4.3 多层感知机的框架实现
摘要:4.2.0 头文件 import torch from torch import nn from d2l import torch as d2l from matplotlib import pyplot as plt # 设置批量大小、学习率、训练轮数 batch_size, lr, num_ep 阅读全文
posted @ 2022-11-04 00:10 yc-limitless 阅读(60) 评论(0) 推荐(0)
4.2 从零实现多层感知机
摘要:4.2.0 头文件 import torch from torch import nn from d2l import torch as d2l from matplotlib import pyplot as plt 4.2.1 下载fashion_mnist数据集 # 定义批量大小 batch_ 阅读全文
posted @ 2022-11-03 23:52 yc-limitless
4.1 激活函数
摘要:4.1.0 头文件 import torch from d2l import torch as d2l from matplotlib import pyplot as plt 4.1.1 Relu激活函数 x = torch.arange(-8.0, 8.0, 0.1, requires_grad 阅读全文
posted @ 2022-11-03 23:06 yc-limitless
3.7 softmax回归的框架实现
摘要:3.7.0 头文件 import torch from torch import nn from d2l import torch as d2l from matplotlib import pyplot as plt 3.7.1 下载fashion_mnist数据集 # 定义批量大小 batch_ 阅读全文
posted @ 2022-11-03 22:52 yc-limitless
3.6 softmax回归的从零实现
摘要:3.6.0 头文件 import torch from IPython import display from d2l import torch as d2l from matplotlib import pyplot as plt 3.6.1 训练结果可视化 class Animator: """ 阅读全文
posted @ 2022-11-03 21:21 yc-limitless
3.5 FashionMNIST训练集和测试集
摘要:3.5.0 头文件 import torch import torchvision from torch.utils import data from torchvision import transforms from d2l import torch as d2l from matplotlib 阅读全文
posted @ 2022-11-03 17:34 yc-limitless
3.3 线性回归模型的框架实现
摘要:3.3.0 头文件 import numpy as np import torch from torch.utils import data from d2l import torch as d2l from torch import nn 3.3.1 Dataloader的详细使用说明 from 阅读全文
posted @ 2022-11-02 17:20 yc-limitless
3.2 线性回归模型的从零实现
摘要:3.2.0 头文件 import random import torch from d2l import torch as d2l 3.2.1 关于yield关键字 # 关于yield关键字 def foo(): print("starting...") while True: res = yiel 阅读全文
posted @ 2022-11-01 21:45 yc-limitless
3.1 定时器和矢量化加速
摘要:import math import time import numpy as np import torch from d2l import torch as d2l class Timer: #@save """记录多次运行时间""" def __init__(self): self.times 阅读全文
posted @ 2022-11-01 15:38 yc-limitless
2.4 计算梯度
摘要:2.4.1 计算梯度 import torch x=torch.arange(4.0,requires_grad=True) print(x) # 输出: # tensor([0., 1., 2., 3.], requires_grad=True) y = 2 * torch.dot(x, x) p 阅读全文
posted @ 2022-11-01 15:14 yc-limitless
2.3 线性代数
摘要:2.3.1 头文件 import torch 2.3.2 标量张量的计算 # 定义两个标量 x = torch.tensor(3.0) y = torch.tensor(2.0) # 加法 print(x + y) # 输出: # tensor(5.) # 减法 print(x - y) # 输出: 阅读全文
posted @ 2022-11-01 14:34 yc-limitless
2.2 读入数据集并对数据集预处理
摘要:2.2.0 头文件 import os import pandas as pd import torch 2.2.1 读取数据集 # 下面一段代码的作用是创建一个人工数据集,并存储在CSV文件中 # 在上一级目录下创建一个data文件夹,exist_ok为false表示如果该文件夹已经存在就报错,为 阅读全文
posted @ 2022-11-01 11:07 yc-limitless
2.1 数据操作
摘要:2.0 头文件 import torch 2.1 创建张量 # 创建一个一维包含12个元素,元素值为0~11的张量 x = torch.arange(12) print(x) # 输出: # tensor([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) # 查看张量 阅读全文
posted @ 2022-11-01 10:04 yc-limitless