随笔分类 -  研究生学习

摘要:ResNet网络 一.手写ResNet网络 (1)对于残差块有两种: 1.有1*1卷积层 Y=Y+conv_1x1(X) 2.无1*1卷积层 Y=Y+X (2)整体ResNet架构 import torch from d2l import torch as d2l from torch import 阅读全文
posted @ 2025-10-18 15:56 Annaprincess 阅读(6) 评论(0) 推荐(0)
摘要:批量归一化层BatchNorm 一.手写BatchNorm(用于理解) import torch from d2l import torch as d2l from torch import nn def batch_norm(X,gamma,beta,moving_mean,moving_val, 阅读全文
posted @ 2025-10-17 14:41 Annaprincess 阅读(10) 评论(0) 推荐(0)
摘要:GoogleNet 一.手写GoogleNet架构 import torch from d2l import torch as d2l from torch import nn from torch.nn import functional as F #1.Inception块 class Ince 阅读全文
posted @ 2025-10-17 10:57 Annaprincess 阅读(6) 评论(0) 推荐(0)
摘要:NiN模型 import torch from torch import nn from d2l import torch as d2l def NiN_block(in_chanels,out_chanels,kernel_size,padding,stride):#NiN块 return nn. 阅读全文
posted @ 2025-10-16 23:16 Annaprincess 阅读(7) 评论(0) 推荐(0)
摘要:VGG使用块的网络 一.手写VGG架构 import torch from torch import nn import d2l #1.VGG块 def VGG_block(nums_conv,in_chanels,out_chanels):#卷积层数,输入通道数,输出通道数 layers=[]#一 阅读全文
posted @ 2025-10-16 20:41 Annaprincess 阅读(7) 评论(0) 推荐(0)
摘要:AlexNet 一.手写AlexNet架构 import torch from torch import nn import d2l net=nn.Sequential( nn.Conv2d(1,96,11,padding=1,stride=4), nn.ReLU(), nn.MaxPool2d(k 阅读全文
posted @ 2025-10-16 20:08 Annaprincess 阅读(8) 评论(0) 推荐(0)
摘要:LeNet 一.网络架构 利用Sequential块实现Lenet import torch from torch import nn #利用Sequential实现Lenet net=nn.Sequential( nn.Conv2d(1,6,5,padding=2), nn.Sigmoid(), 阅读全文
posted @ 2025-10-15 15:56 Annaprincess 阅读(2) 评论(0) 推荐(0)
摘要:一.手写池化 import torch def pool(X,pool_size,mode='max'):#手写池化,这里mode参数用于表示是何种池化默认最大池化 p_h,p_w=pool_size#poolsize表示池化窗口大小传入一个元组 Y=torch.zeros((X.shape[0]- 阅读全文
posted @ 2025-10-15 15:19 Annaprincess 阅读(6) 评论(0) 推荐(0)
摘要:一.互相关运算(原矩阵乘以卷积核) X为原矩阵,K为卷积核,Y 为结果。shape[0]表示行数,h行数,w列数 import torch def corr2d(X,K): h,w=K.shape #获得卷积核的行数h,列数w Y=torch.zeros((X.shape[0]-h+1,X.shap 阅读全文
posted @ 2025-10-13 21:24 Annaprincess 阅读(8) 评论(0) 推荐(0)
摘要:第二章Pycharm和Jupiter 一.Pycharm 在python console里的操作如下: 右侧会像matlab一样显示变量 二.Jupyter 1.下载Jupyter所需要的包 先进入环境(激活) conda activate pytorchnow conda install nb_c 阅读全文
posted @ 2025-09-26 16:45 Annaprincess 阅读(8) 评论(0) 推荐(0)
摘要:一.创建anaconda虚拟环境(以后如果没有特殊要求可以用当前已经创建好的环境) 在Anaconda Prompt里创建环境 现在是创建一个名为pytorchnow的虚拟环境,用python3.9为了匹配要安装的pytorch conda create -n pytorchnow python=3 阅读全文
posted @ 2025-09-26 16:16 Annaprincess 阅读(30) 评论(0) 推荐(0)