自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(65)
  • 资源 (1)
  • 收藏
  • 关注

原创 pip install huggingface_hub时报错

pip install huggingface_hub时报错:可以尝试:pip install --upgrade huggingface_hub 进行安装

2023-10-18 16:45:29 1222

原创 Classifier-Free Guidance

扩散模型的基础理解

2023-10-12 08:51:59 254

原创 nn.embedding

来源于博主: https://zhuanlan.zhihu.com/p/647536930,感觉写的清晰明了!

2023-09-15 09:24:13 184

原创 Detectron2 安装踩坑

设备:NVIDIA GeForce RTX 3090。

2023-09-13 17:00:32 1423 2

原创 numpy库常用函数——np.arange()函数

【代码】numpy库常用函数——np.arange()函数。

2023-09-12 11:39:27 3658

原创 安装高版本python3.10时出现错误:Fatal Python error: init_fs_encoding: failed to get the Python

【代码】安装高版本python3.10时出现错误:Fatal Python error: init_fs_encoding: failed to get the Python。

2023-09-11 17:21:17 1134 1

原创 pip安装skimage的方法

在安装时,可能会报错误:

2023-09-08 10:59:55 1864

原创 ERROR: Failed building wheel for mpi4py

在深度学习虚拟环境中使用pip方式安装mpi4py时,出现错误:ERROR: Failed building wheel for mpi4py,无法安装成功时,可以尝试使用conda的方式:conda install mpi4py。

2023-09-08 10:54:57 524

原创 np.squeeze()

【代码】np.squeeze()

2023-06-24 14:35:33 1020

原创 python读取包含中文的txt

然后,使用 chardet 模块检测文件的编码格式,并将检测出来的编码格式传递给 open 函数,以正确的编码格式读取文件内容。需要注意的是,在读取文件时,应该始终在 open 函数中指定要使用的文件编码格式,以避免出现乱码或者解码错误。如果文件是 UTF-8 编码格式,则可以使用 Python 内置的 open 函数读取文件。如果不知道文件的编码格式,则可以使用第三方模块 chardet 来检测文件的编码格式。读取包含汉字的文本文件,需要注意文件的编码格式。

2023-06-19 14:30:07 1884

原创 VIT算法模型源码调试时:ModuleNotFoundError: No module named ‘utils.scheduler‘

ModuleNotFoundError: No module named 'utils.scheduler'

2022-12-13 09:21:33 330 1

原创 详解 torch.max 函数

torch.max(input) → Tensor返回输入tensor中所有元素的最大值例子:import torcha = torch.randn(1, 3) # a是随机生成的,每次运行结果都不一样a_max = torch.max(a)print(a_max)输出:tensor([[-0.6409, 0.4322, -0.6669]])tensor(0.4322)torch.max(input, dim, max=None, max_indices=None) -

2022-05-02 10:38:53 1390

原创 关于Seq2Seq的一些有用的博客、简书等

关于在学习Seq2Seq时查阅有帮助的网址的汇总,具体内容还没来得及整理,先记录一下。链接1: https://www.jianshu.com/p/1c6b1b0cd202.链接2: https://www.jianshu.com/p/b2b95f945a98.链接3: https://cloud.tencent.com/developer/ask/sof/1816826.链接4: https://blog.csdn.net/chuxuezhew/article/details/97890995.

2022-04-11 20:58:55 872

原创 Windows中修改Mendeley字体及大小

Windows中修改Mendeley字体及大小的方法。1、适用于Windows102、键入win+R 打开运行窗口,输入regedit 命令打开注册表。3、在注册表上侧路径框输入HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\GRE_Initialize,定位到对应目录。如图所示:4、修改GUIFont.Facename = Microsoft YaHei UI(或其他字体),修改GUIFont.Height =

2022-04-09 16:07:05 2728

原创 python 中 np.arange()的使用

np.arange() :函数返回一个有终点和起点的固定步长的排列,如[0, 1, 2, 3, 4, 5, 6, 7],起点是0,终点是7,步长为1。参数个数情况: np.arange()函数分为一个参数,两个参数,三个参数三种情况:一个参数时,参数值为终点,起点取默认值0,步长取默认值1。两个参数时,第一个参数为起点,第二个参数为终点,步长取默认值1。三个参数时,第一个参数为起点,第二个参数为终点,第三个参数为步长。其中步长支持小数...

2022-04-02 19:59:30 6819 1

转载 numpy中np.random.choice()的用法详解及其参考代码

处理数据时经常需要从数组中随机抽取元素,这时候就需要用到np.random.choice()官方解释:numpy.random.choice(a, size=None, replace=True, p=None)Generates a random sample from a given 1-D arrayNew in version 1.7.0.Parameters: a : 1-D array-like or intIf an ndarray, a random sample is g

2022-02-28 09:59:15 5584 1

原创 AttributeError: module ‘tensorflow‘ has no attribute ‘placeholder‘

当你出现这个问题时,说明在tf2下使用了tf1的API。1.参看版本号是否使用错误在pycharm下,找到工程,然后输出下面命令参看版本import tensorflow as tf #载入tensorflow环境print(tf.__version__) #查看tensorflow版本会打印tensorflow版本,应该是2.0的版本。2.把代码进入tf环境中下面的代码替换import tensorflow as tf替换为:import tensorflow.compat

2022-02-27 16:41:22 801

原创 random.sample函数

random.sample函数返回包含列表中任意两个项目的列表:import randoma = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]for i in range(3): slice_a = random.sample(a, 5) # 从list中随机获取5个元素,作为一个片断返回 print(slice_a) print(a, '\n') # 原有序列并没有改变输出:[15, 7, 10, 13,

2022-02-25 11:29:05 7282

原创 【Python】np.linspace用法介绍

np.linspace主要用来创建等差数列。np.linspace参数:numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0)Return evenly spaced numbers over a specified interval.(在start和stop之间返回均匀间隔的数据)Returns num evenly spaced samples, calculated ove

2022-02-25 10:05:05 7751

原创 使用pandas将numpy中的数组数据保存为csv文件的方法

如果想保存numpy中的数组元素到一个文件中,在这方面,pandas工具的使用就会让工作方便很多。下面通过一个简单的小例子来演示一下。首先,创建numpy中的数组:import numpy as npimport pandas as pdarr1 = np.arange(81).reshape(9, 9)print("arr1的type: {}".format(type(arr1)))print("arr1的shape: {}".format(arr1.shape))print(arr1)

2022-02-18 10:43:30 4946

原创 GAN-详解BCELoss和BCEWithLogitsLoss

一、BCELoss()生成对抗网络的所使用到的loss函数BCELoss和BCEWithLogitsLoss其中BCELoss的公式为:其中y是target,x是模型输出的值。二、例子import torchfrom torch import autogradfrom torch import nnimport mathinput = autograd.Variable(torch.tensor([[ 1.9072, 1.1079, 1.4906], [-0.658

2022-02-17 17:37:05 2793

原创 RuntimeError: CUDA out of memory.

在学习3D点云:Pointnet2时出现以下错误:RuntimeError: CUDA out of memory. Tried to allocate 256.00 MiB (GPU 0; 11.00 GiB total capacity; 1.90 GiB already allocated; 7.46 GiB free; 2.03 GiB reserved in total by PyTorch)在配置参数是batch_size设定是的太大,由于硬件限制,改小一些可以运行了。网上还有一篇博客写

2022-02-15 19:21:57 1130

原创 Pytorch框架之tensor.equal和tensor.eq--判断相等

行人重识别Relation-Aware Global Attention的部分代码。 N = dist_mat.size(0) # 8 is_pos = labels.expand(N, N).eq(labels.expand(N, N).t()) #print(is_pos.shape) is_neg = labels.expand(N, N).ne(labels.expand(N, N).t()) #print(is_neg.shape)一、测试eq()函数:import torch

2022-02-14 11:07:39 1356

原创 pytorch中卷积函数参数

对于pytorch深度学习框架,二维卷积nn.Conv2d对于宽度和高度都进行卷积运算,其定义如下:class torch.nn.Conv2d(in_channels, out_channels, kennel_size, stride=1, padding=0, dilation=1, groups=1, bias=true)in_channels(int) 输入特征图的通道数out_channels(int) 输出特征图的通道数kenal_size(int or tuple) 卷积核大小st

2022-02-13 22:17:13 980

原创 Pytorch——tensor.expand_as()函数

行人重识别Relation-Aware Global Attention的部分代码。 W_ys = self.W_spatial(ys) # W_ys的维度是[8, 1, 64, 32] 是空间位置特征权重 # print(W_ys.shape) # x的维度是[8, 256, 64, 32] if not self.use_channel: out = F.sigmoid(W_ys.expand_as(x)) * x # 位置特征,不同特征图,位置相同的 re

2022-02-13 21:52:23 1150

原创 permute函数

permute():将tensor的维度换位。permute(多维数组,[维数换位顺序])比如:a=rand(2,3,4); %a是一个三维数组,各维的长度分别为:2,3,4permute(a,[2,1,3]) %实现了交换第一维和第二维,a变成3*2*4的矩阵

2022-02-13 16:26:08 1126

原创 torch.long()

torch.long():向下取整>>> b1 = torch.rand(3,3)>>> b1tensor([[0.7498, 0.2052, 0.9352], [0.1171, 0.2046, 0.1682], [0.3003, 0.7483, 0.0089]])>>> b1.long()tensor([[0, 0, 0], [0, 0, 0], [0, 0, 0]]).

2022-02-10 17:19:26 12833 4

原创 numpy.repeat()

numpy.repeat(a, repeats, axis=None)a:输入矩阵repeats:每个元素重复的次数axis:需要重复的维度Returns:输出矩阵>>> np.repeat(3, 4)array([3, 3, 3, 3]) #每个元素重复4次>>> x = np.array([[1,2],[3,4]])>>> np.repeat(x, 2)array([1, 1, 2, 2, 3, 3, 4, 4]) #每个元

2022-02-10 10:08:45 993 1

转载 PyTorch 中的 ModuleList 和 Sequential: 区别和使用场景

PyTorch 中有一些基础概念在构建网络的时候很重要,比如 nn.Module, nn.ModuleList, nn.Sequential,这些类我们称之为容器 (containers),因为我们可以添加模块 (module) 到它们之中。这些容器之间很容易混淆,本文中我们主要学习一下 nn.ModuleList 和 nn.Sequential,并判断在什么时候用哪一个比较合适。本文中的例子使用的是 PyTorch 1.0 版本。nn.ModuleList首先说说 nn.ModuleList 这个类,

2022-02-08 16:29:06 465

原创 LeetCode-206.反转链表

一、题目描述给你单链表的头节点 head ,请你反转链表,并返回反转后的链表。实例:输入:head = [1,2,3,4,5]输出:[5,4,3,2,1]二、解法https://leetcode-cn.com/problems/reverse-linked-list/solution/shi-pin-jiang-jie-die-dai-he-di-gui-hen-hswxy/.2.1. 迭代解法public: ListNode* reverseList1(ListNode* h

2022-02-08 11:12:17 282

原创 LeetCode-两数之和

由于没有转载成功,只能出此下策。原文链接:https://blog.csdn.net/qq_44106937/article/details/116146592有一篇讲哈希表的:关联容器:unordered_map详细介绍 值得参考,https://blog.csdn.net/hk2291976/article/details/51037095...

2022-02-07 20:59:00 335

原创 python matplotlib画图设置坐标轴刻度的字体大小

import matplotlib.pyplot as plt plt.xticks([1, 2, 3, 4, 5, 6, 7, 8]) plt.tick_params(labelsize=13) #刻度字体大小13

2022-02-05 16:52:19 19597

原创 nn.BatchNorm2d()函数详解

if module_def["type"] == "convolutional": # 如果类型是convolutional,添加Con卷积层conv_{module_i} bn = int(module_def["batch_normalize"]) filters = int(module_def["filters"]) kernel_size = int(module_def["size"]) ...

2022-02-05 09:27:36 19931

转载 Pytorch使用 nn.ModuleList() 和nn.Sequential()编写神经网络模型

一、使用传统方法创建模型import numpy as npimport torchimport torch.nn as nn#准备数据data=np.linspace(-2*np.pi,2*np.pi,400) # -2PI 到 2PI 区间分成400份的所有点x=torch.tensor(data.reshape(400,-1),dtype=torch.float)y=torch.tensor(np.sin(data.reshape(400,-1)),dtype=torch.float

2022-02-05 09:20:56 589

原创 F.pad函数

1. F.pad函数定义F.pad是pytorch内置的tensor扩充函数,便于对数据集图像或中间层特征进行维度扩充,下面是pytorch官方给出的函数定义。torch.nn.functional.pad(input, pad, mode='constant', value=0)函数变量说明:input需要扩充的tensor,可以是图像数据,抑或是特征矩阵数据pad扩充维度,用于预先定义出某维度上的扩充参数mode扩充方法,’constant‘, ‘reflect’ or ‘repl

2022-02-03 12:40:25 1053 1

转载 pytorch中squeeze()和unsqueeze()函数介绍

一、unsqueeze()函数 1. 首先初始化一个a 可以看出a的维度为(2,3) 2. 在第二维增加一个维度,使其维度变为(2,1,3) 可以看出a的维度已经变为(2,1,3)了,同样如果需要在倒数第二个维度上增加一个维度,那么使用b.unsqueeze(-2) 二、squeeze()函数介绍 1. 首先得到一个维度为(1,2,3)的tensor(张量) 由图中可以看出c的维度为(1,...

2022-02-03 11:03:44 362

转载 Python File readlines() 方法

概述readlines() 方法用于读取所有行(直到结束符 EOF)并返回列表,该列表可以由 Python 的 for… in … 结构进行处理。如果碰到结束符 EOF 则返回空字符串。语法readlines() 方法语法如下:fileObject.readlines( );参数无。返回值返回列表,包含所有的行。实例以下实例演示了 readlines() 方法的使用:文件 runoob.txt 的内容如下:1:www.runoob.com2:www.runoob.com3:

2022-01-29 10:39:09 435

转载 Python strip()方法

描述Python strip() 方法用于移除字符串头尾指定的字符(默认为空格或换行符)或字符序列。注意:该方法只能删除开头或是结尾的字符,不能删除中间部分的字符。语法strip()方法语法:str.strip([chars]);参数chars -- 移除字符串头尾指定的字符序列。返回值返回移除字符串头尾指定的字符生成的新字符串。实例以下实例展示了strip()函数的使用方法:#!/usr/bin/python# -*- coding: UTF-8 -*- str = "0

2022-01-29 10:34:02 151

原创 如何在浏览器中打开jupyter notebook

1、找到IPYNB后缀的文件所在文件夹2、在导航栏中输入cmd后回车出现:3、输入:jupyter notebook,回车后就会在浏览器中打开相应的文件。

2022-01-26 15:49:54 8720

转载 LaTeX(WinEdt)编译错误时,快速定位源文件中出错位置

1 编译停止时找到在光标闪烁的位置   2 在红色圈的这儿输入 e 回车   3 找到编译不过的位置  

2022-01-07 16:32:37 2364

数据结构与算法365天刷题特训营-资料.zip

关于数据结构和算法的资料,内容知识体系完备,通俗易懂,包括PPT和刷题源代码。结合视频讲解,能很好地掌握数据结构和算法,为计算机编程打下坚实基础。

2021-09-25

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除