摘要: 问题描述: 原因: 代码是没问题的,可直接运行。 主要原因是因为vscode的插件模块检测不到模块,在于cv2模块下还有cv2模块。 解决: 1 from cv2 import cv2 as cv2 阅读全文
posted @ 2021-03-25 11:19 一剑光寒十四州 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 需求描述: 判断一个目录是否存在,若不存在,建立该目录。并将文件复制到该目录下。 1 import os 2 import shutil 3 4 def copy_file_to_dir(obj_dir, obj_path): 5 if not os.path.exists(obj_dir): 6 阅读全文
posted @ 2021-03-24 15:52 一剑光寒十四州 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 图像标准化 input:输入的图像像素值 mean(input):输入图像像素的均值 std(input):输入图像像素的标准差 将原始数据映射到均值为0、标准差为1的分布上 y = (x - mean)/σ :基于原始数据的均值(mean)和标准差(standard deviation)进行数据的 阅读全文
posted @ 2021-03-24 13:48 一剑光寒十四州 阅读(1281) 评论(0) 推荐(0) 编辑
摘要: MobileNetv1模型 PyTorch自带的MobileNetV1 没有实现MobileNetV1 详情参考:https://pytorch.org/vision/stable/models.html 自己搭建 1 import torch 2 import torch.nn as nn 3 i 阅读全文
posted @ 2021-03-22 15:09 一剑光寒十四州 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 1、深度可分离卷积 Depthwise Separable Convolution (一)结构 实质上是将标准卷积分成了两步:depthwise卷积和pointwise卷积。 标准卷积: depthwise卷积: pointwise卷积: 2、代码实现 [32, 3, 224, 224] ——> [ 阅读全文
posted @ 2021-03-19 16:19 一剑光寒十四州 阅读(4309) 评论(0) 推荐(2) 编辑
摘要: 模型搭建 0、VGG模型 1、torchvision自带的VGG模型 1 import torch 2 import torchvision 3 from torchsummary import summary 4 5 model = torchvision.models.vgg13(num_cla 阅读全文
posted @ 2021-03-18 16:32 一剑光寒十四州 阅读(392) 评论(0) 推荐(0) 编辑
摘要: 1 torch.nn.Flatten(start_dim=1, end_dim=-1) Parameters 1 start_dim – first dim to flatten (default = 1). 2 end_dim – last dim to flatten (default = -1 阅读全文
posted @ 2021-03-17 15:35 一剑光寒十四州 阅读(455) 评论(0) 推荐(0) 编辑
摘要: 1 torch.nn.Linear(in_features, out_features, bias=True) 用于设置网络中的全连接层。 输入与输出均是二维张量。 输入与输出形状是 [batch_size, size]。 之前一般使用view或nn.Flatten()将4维张量变为2维张量。 Pa 阅读全文
posted @ 2021-03-17 14:52 一剑光寒十四州 阅读(602) 评论(0) 推荐(0) 编辑
摘要: torch.nn.MaxPool2d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False) Parameters 1 kernel_size – the size of the 阅读全文
posted @ 2021-03-17 14:29 一剑光寒十四州 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 1 torch.nn.Conv2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros') Parameters 1 in_ 阅读全文
posted @ 2021-03-16 14:57 一剑光寒十四州 阅读(106) 评论(0) 推荐(0) 编辑