![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pytorch
穹镜
这个作者很懒,什么都没留下…
展开
-
ImportError: libtorch_cuda_cu.so: cannot open shared object file: No such file or directory,mmdet安装报
安装torch torchvision时一定要记住时按章cuda10.2,(我报错的原因就是因为装的是cuda11.3)github前面说了,没注意导致后面mmcv和mmdet一直报错。正确方法:注意一定要按照顺序,先手动安装MMDetection,再回头上一层文件夹,执行下面的命令。指定mmdet版本安装(错误方法,他指定了只能按照文档介绍的方式安装,不能用pip)安装之前强制更新了一下conda要不然一直报setuptools那个错误,gcc安装 c-compiler。指定mmcv版本安装。原创 2023-09-04 10:44:23 · 3125 阅读 · 0 评论 -
Attention学习笔记
注意力机制学习代码原创 2022-04-10 21:33:37 · 560 阅读 · 0 评论 -
efficientnet 代码
efficient代码笔记来源 :https://github.com/WZMIAOMIAO/deep-learning-for-image-processing/blob/master/pytorch_classification/Test9_efficientNetimport mathimport copyfrom functools import partialfrom collections import OrderedDictfrom typing import Optional,原创 2021-07-05 13:55:41 · 931 阅读 · 1 评论 -
从头开始使用 U-NET 实现语义分割
u-net结构图代码地址:https://github.com/aladdinpersson/Machine-Learning-Collection/tree/master/ML/Pytorch/image_segmentation/semantic_segmentation_unetmodel.pyimport torchimport torch.nn as nnimport torchvision.transforms.functional as TFclass DoubleConv(原创 2021-07-04 19:21:58 · 626 阅读 · 0 评论 -
Einsum: numpy,pytorch and Tensorflow
EINSUM IS ALL YOU NEED如果你和我一样,你会发现很难记住 PyTorch/TensorFlow 中用于计算点积、外积、转置和矩阵向量或矩阵矩阵乘法的所有不同函数的名称和签名。Einsum 表示法是表达所有这些以及对张量的复杂操作的一种优雅方式,本质上是使用特定于领域的语言。除了不必记住或定期查找特定库函数之外,这还有其他好处。一旦你理解并使用了 einsum,你将能够更快地编写更简洁高效的代码。当不使用 einsum 时,很容易引入不必要的张量整形和转置,以及可以省略的中间张量原创 2021-07-04 11:59:26 · 274 阅读 · 0 评论 -
Pytorch Quick Tip: Weight Initialization
pytorch_init_weightsExample code of how to initialize weights for a simple CNN network.# Importsimport torch.nn as nn # All neural network modules, nn.Linear, nn.Conv2d, BatchNorm, Loss functionsimport torch.nn.functional as F # All functions that do原创 2021-07-04 10:51:30 · 171 阅读 · 0 评论 -
Pytorch Quick Tip: Using a Learning Rate Scheduler
学习率策略如何使用简单的学习率调度程序的示例代码,在这种情况下,使用学习率调度程序在 MNIST 数据集上进行(非常)小而简单的前馈网络训练。在这种情况下,使用 ReduceLROnPlateau 调度程序,但可以轻松更改为任何其他可用的调度程序。# Importsimport torchimport torch.nn as nn # All neural network modules, nn.Linear, nn.Conv2d, BatchNorm, Loss functionsimpor原创 2021-07-04 10:47:30 · 118 阅读 · 0 评论 -
Reproducible Results and Deterministic Behavior
设置随机种子import random, torch, os, numpy as npdef seed_everything(seed=42): os.environ['PYTHONHASHSEED'] = str(seed) random.seed(seed) np.random.seed(seed) torch.manual_seed(seed) # if using cuda torch.cuda.manual_seed(seed) tor原创 2021-07-04 10:31:01 · 60 阅读 · 0 评论 -
PyTorch Quick Tip: How to get a Progress Bar(进度条)
进度条import torchimport torch.nn as nnfrom tqdm import tqdmfrom torch.utils.data import TensorDataset, DataLoader# Create a simple toy dataset example, normally this# would be doing custom class with __getitem__ etc,# which we have done in custom dat原创 2021-07-03 21:13:06 · 664 阅读 · 0 评论 -
Calculate Mean and Standard Deviation of Data
import torchimport torchvision.transforms as transformsfrom torch.utils.data import DataLoaderimport torchvision.datasets as datasetsfrom tqdm import tqdmdevice = torch.device("cuda" if torch.cuda.is_available() else "cpu")train_set = datasets.CIFAR原创 2021-07-03 20:47:42 · 209 阅读 · 0 评论 -
Pytorch TensorBoard Tutorial
TensorBoard# Pytorch 1.4.0# pip install tb-nightly如何在 PyTorch 中使用 TensorBoard 的示例代码。这段代码使用了来自 TensorBoard 的许多不同的功能,并试图以紧凑的方式将它们全部包含在内# Importsimport torchimport torchvisionimport torch.nn as nn # All neural network modules, nn.Linear, nn.Conv2d,原创 2021-07-03 20:08:48 · 167 阅读 · 0 评论 -
PYTORCH COMMON MISTAKES
1.Didn’t overfit a single batchdata, targets = next(iter(train_loader))import torchimport torchvision # torch package for vision related thingsimport torch.nn.functional as F # Parameterless functions, like (some) activation functionsimport torchvis原创 2021-07-03 19:20:05 · 97 阅读 · 0 评论 -
How to deal with Imbalanced Datasets in PyTorch - Weighted Random Sampler Tutorial
处理imblance数据数据集两类:金毛100:哈士奇1Methods for dealing with imbalanced datasets:Oversampling即不同的数据增强Class weighting给少的数据集更大的权重loss_fn=nn.CrossEntrophyLoss(weight=torch.tensor([1,50,12...]))import torchimport torchvision.datasets as datasetsimport o原创 2021-07-03 16:51:00 · 257 阅读 · 0 评论 -
Albumentations Tutorial for Data Augmentation (Pytorch focused)
对比torchvision优势1.Faster than torchvision on every batch2.Support for more tasks like segmentation and detection which is a lot harder to do in torchvisionimages:cat_dogs:数据集每个文件夹里有相应的图片文件1.classification.pyimport cv2import albumentations as Aim原创 2021-07-03 16:15:10 · 220 阅读 · 5 评论 -
Pytorch Data Augmentation using Torchvision
介绍展示了如何在 CIFAR10 数据集上使用转换(可能不需要很多)以及在小型 CNN 网络上进行训练的小示例Shows a small example of how to use transformations (perhaps unecessarily many)on CIFAR10 dataset and training on a small CNN toy network.import torchimport torch.nn as nn # All neural network mo原创 2021-07-03 11:07:25 · 312 阅读 · 0 评论 -
How to build custom Datasets for Text in Pytorch
images文件夹下面为图像文件caption如下图所示imagefile ,caption目的我们想要转换文本 -> 数值我们需要一个将每个单词映射到索引的词汇表我们需要设置一个 Pytorch 数据集来加载数据设置每个批次的填充(所有示例都应该是排序好的相同的 seq_len 和设置 dataloader) # 注意,加载图像比文本更容易!mport os # when loading file pathsimport pandas as pd # for look..原创 2021-07-03 10:37:56 · 122 阅读 · 0 评论 -
How to build custom Datasets for Images in Pytorch
custom dataset文件目录如下所示cats-dogs-resized目录下文件cats_dogs.csv:文件名 和标签create class load datasetcustom_dataset.py 文件:如何在 Pytorch 中创建自定义数据集的示例。在这种情况下,我们在一个单独的文件夹中有猫和狗的图像,以及一个包含 jpg 文件名称和目标标签的 csv 文件(0 代表猫,1 代表狗)。# Importsimport torchimport torch.nn原创 2021-07-03 09:56:44 · 185 阅读 · 0 评论 -
pytorch_pretrain_finetune
introduction这是一个如何从 PyTorch 加载预训练模型 (VGG16) 的小示例,并对其进行修改以在 CIFAR10 数据集上进行训练。相同的方法可以很好地推广到其他数据集,但可能需要更改对网络的修改。# Importsimport torchimport torchvisionimport torch.nn as nn # All neural network modules, nn.Linear, nn.Conv2d, BatchNorm, Loss functionsi原创 2021-07-02 20:31:06 · 244 阅读 · 1 评论 -
How to save and load models in Pytorch
Save and load checkpoint of a model如何保存和加载模型检查点的小代码示例。这个例子没有执行任何训练。# Importsimport torchimport torchvisionimport torch.nn as nn # All neural network modules, nn.Linear, nn.Conv2d, BatchNorm, Loss functionsimport torch.optim as optim # For all Opti原创 2021-07-02 19:52:11 · 69 阅读 · 0 评论 -
pytorch_bidirectional_lstm
bidirectional LSTMExample code of a simple bidirectional LSTM on the MNIST dataset.Hyperparameters# Hyperparametersinput_size = 28sequence_length = 28num_layers = 2hidden_size = 256num_classes = 10learning_rate = 0.001batch_size = 64num_epochs =原创 2021-07-02 19:35:43 · 998 阅读 · 0 评论 -
pytorch_rnn_gru_lstm
pytorch_rnn_gru_lstmExample code of a simple RNN, GRU, LSTM on the MNIST dataset.原创 2021-07-02 19:26:47 · 149 阅读 · 0 评论 -
pytorch_simple_CNN
convolutional neural network (CNN)using the PyTorch librarymodelclass CNN(nn.Module): def __init__(self, in_channels=1, num_classes=10): super(CNN, self).__init__() self.conv1 = nn.Conv2d( in_channels=in_channels,原创 2021-07-02 09:45:15 · 445 阅读 · 0 评论 -
pytorch_simple_fullynet
Fully connected neural network simpleImportsimport torchimport torchvision # torch package for vision related thingsimport torch.nn.functional as F # Parameterless functions, like (some) activation functionsimport torchvision.datasets as datasets #原创 2021-07-01 23:38:52 · 83 阅读 · 1 评论 -
pytorch_tensorbasics
pytorch 学习tensorInitialization of a TensorTensor Mathematical Operations and ComparisonTensor IndexingTensor Reshaping原创 2021-07-01 23:24:24 · 131 阅读 · 0 评论