摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
import torch from d2l import torch as d2l from torch import nn # 多输入通道互相关运算 def corr2d_multi_in(x,k): # zip对每个通道配对,返回一个可迭代对象,其中每个元素是一个(x,k)元组,表示一个输入通道 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文