打赏
摘要: import torch from torch import nn from torch.nn import functional as F from d2l import torch as d2l class Inception(nn.Module): # c1-c4是每条路径的输出通道数 def 阅读全文
posted @ 2023-08-06 14:47 不像话 阅读(4) 评论(0) 推荐(0) 编辑
摘要: import torch from torch import nn from d2l import torch as d2l def nin_block(in_channels,out_channels,kernel_size,strides,padding): return nn.Sequenti 阅读全文
posted @ 2023-08-06 14:45 不像话 阅读(8) 评论(0) 推荐(0) 编辑
摘要: import torch from torch import nn from d2l import torch as d2l def vgg_block(num_convs,in_channels,out_channels): layers = [] for _ in range(num_convs 阅读全文
posted @ 2023-08-06 14:44 不像话 阅读(12) 评论(0) 推荐(0) 编辑
摘要: import torch from torch import nn from d2l import torch as d2l net = nn.Sequential( # (224-11+1+2)/4=54 nn.Conv2d(1,96,kernel_size=11,stride=4,padding 阅读全文
posted @ 2023-08-06 14:41 不像话 阅读(3) 评论(0) 推荐(0) 编辑
摘要: import torch from torch import nn from d2l import torch as d2l class Reshape(torch.nn.Module): def forward(self,x): # 批量大小默认,输出通道为1 return x.view(-1,1 阅读全文
posted @ 2023-08-06 14:39 不像话 阅读(13) 评论(0) 推荐(0) 编辑
摘要: import torch from torch import nn from d2l import torch as d2l # 实现池化层的正向传播 def pool2d(x,pool_size,mode='max'): # 获取窗口大小 p_h,p_w=pool_size # 获取偏移量 y=t 阅读全文
posted @ 2023-08-06 14:35 不像话 阅读(5) 评论(0) 推荐(0) 编辑
摘要: import torch from d2l import torch as d2l from torch import nn # 多输入通道互相关运算 def corr2d_multi_in(x,k): # zip对每个通道配对,返回一个可迭代对象,其中每个元素是一个(x,k)元组,表示一个输入通道 阅读全文
posted @ 2023-08-06 14:33 不像话 阅读(28) 评论(0) 推荐(0) 编辑
摘要: import torch from torch import nn def comp_conv2d(conv2d,x): # 在维度前面加上通道数和批量大小数1 x=x.reshape((1,1)+x.shape) # 得到4维 y=conv2d(x) # 把前面两维去掉 return y.resh 阅读全文
posted @ 2023-08-06 14:31 不像话 阅读(18) 评论(0) 推荐(0) 编辑
摘要: import torch from torch import nn from d2l import torch as d2l def corr2d(x,k): """计算二维互相关运算""" # 获取卷积核的高和宽 h,w=k.shape # 输出的高和宽 y=torch.zeros((x.shap 阅读全文
posted @ 2023-08-06 14:29 不像话 阅读(10) 评论(0) 推荐(0) 编辑
摘要: import os os.environ['KMP_DUPLICATE_LIB_OK']='True' import hashlib import tarfile import zipfile import requests import numpy as np import pandas as p 阅读全文
posted @ 2023-08-06 13:37 不像话 阅读(7) 评论(0) 推荐(0) 编辑