
pytorch
spark-aixin
明明知道敏感不好,偏偏却特别敏感!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
读书笔记--pytorch基础
文章目录1、保存设置1、保存设置def zipdir(path, ziph): files = os.listdir(path) for file in files: if file.endswith(".py") or file.endswith("cfg"): ziph.write(os.path.join(path, file)) if file.endswith("cfg"): os.原创 2020-08-29 11:45:46 · 192 阅读 · 0 评论 -
pytorch可视化预处理的结果,附带张量转img的函数
import matplotlib.pyplot as pltimport numpy as npimport torchvision.transforms as Tfrom PIL import Imageimg = Image.open('0703.jpg')plt.imshow(np.array(img))plt.savefig("原图.png")plt.show()# 原图-82# transform = T.Resize((82,82))# result = transfo原创 2020-07-04 20:37:12 · 992 阅读 · 0 评论 -
pytorch--模型训练细节、数据格式、预训练模型、张量
1、支持的数据格式: batch_size,input_channel,input_h,input_w2、input_tensor = torch.rand(4, 4, 128, 128)随机生成一个4维张量,将其输入到模型内3、https://blog.csdn.net/weixin_42118374/article/details/103761795–修改预训练模型4、variable是torch的数据类型、grad_fn记录了张量求导过程中的运算方法张量的8个属性:data、dtype、sh原创 2020-06-02 10:21:11 · 1318 阅读 · 0 评论 -
pytorch--输出模型每一层的结构
首先定义一个模型的类,例如class Resnet()然后实例化这个类,例如resnet = Resnet()再在主程序中print(resnet.层名称)即可输出,一般层名称会自己跳出来原创 2020-05-31 23:16:22 · 3152 阅读 · 0 评论 -
pytorch--自适应池化Adaptive Pooling
MaxPool1d(kernel_size=math.ceil(inputsize / outputsize), stride=math.floor(inputsize / outputsize), padding=0)只要给输入和输出,黑箱操作自动得出结果举个栗子:如果输入是9,想输出4MaxPool1d(kernel_size=math.ceil(9 / 4), stride=math.floor(9 / 4), padding=0)kernel_size=math.ceil(9 / 4)=3原创 2020-05-22 19:28:56 · 1142 阅读 · 0 评论 -
输出model的具体层及细节设置--torch实现
def resnet32(): 返回一个resnet20的类if __name__ == "__main__": for net_name in __all__: if net_name.startswith('resnet'): #print(net_name) test(globals()[net_name...原创 2020-04-09 08:47:17 · 923 阅读 · 0 评论 -
全局平均池化---torch实现
# target output size of 5x7m = nn.AdaptiveAvgPool2d((5,7))input = torch.randn(1, 64, 8, 9)output = m(input)# output.shape=(1,64,5,7)# target output size of 7x7 (square)m = nn.AdaptiveAvgPool2...原创 2020-04-06 23:48:30 · 4234 阅读 · 0 评论 -
数据集的图片尺寸与想用的网络默认输入尺寸不匹配怎么办?--torch实现
修改数据集图片尺寸以适应现有网络的输入?这是个方法:model_vgg = vgg(include_top=False, weights='imagenet', input_shape=(48, 48, 3))# 选择imagnet,会选择当年大赛的初始参数# include_top=False 去掉最后3层的全连接层看源码可知...原创 2020-04-04 16:05:46 · 8177 阅读 · 2 评论 -
pytorch学习1-张量及基本操作、计算图、自动求导系统(学习笔记)
torch实现原创 2020-07-29 15:45:02 · 430 阅读 · 0 评论 -
RuntimeError: a leaf Variable that requires grad has been used in an in-place operation.a += torch.o
叶子节点不能执行in-place操作,因为在进行前向传播的时候得到的是叶子结点的地址,再进行反向传播的时候这个地址不变才不会报错,地址改变了就会出错要将a += torch.ones((1, ))改为a = a + torch.ones((1, ))...原创 2020-02-22 20:55:43 · 10333 阅读 · 4 评论 -
pytorch学习绪论
本节第二部分介绍pytorch中的数据结构——Tensor,Tensor是PyTorch中最基础的概念,其参与了整个运算过程,因此本节将介绍张量的概念和属性,如data, device, dtype等,并介绍tensor的基本创建方法,如直接创建、依数值创建和依概率分布创建等。1、张量2、张量的创建---3种方法2.1共享内存举例:(改一个,另一...原创 2020-07-29 14:33:20 · 157 阅读 · 0 评论