python
千岁千岁千千岁_
一树梨花压海棠。
展开
-
python里面的.item()用法
python里面的.item()用法原创 2022-07-28 16:33:28 · 1946 阅读 · 0 评论 -
AttributeError: ‘DistributedDataParallel‘ object has no attribute ‘XXXX‘
AttributeError: 'DistributedDataParallel' object has no attribute 'xxxx'原创 2022-06-16 20:00:54 · 6194 阅读 · 3 评论 -
TypeError: torch.nn.modules.batchnorm.BatchNorm2d is not a Module subclass
改网络时遇到的问题:TypeError: torch.nn.modules.batchnorm.BatchNorm2d is not a Module subclasstorch.nn.modules.batchnorm.BatchNorm2d原创 2022-06-10 11:51:11 · 770 阅读 · 0 评论 -
TensorFlow中相关的维度处理函数
TensorFlow中相关的维度处理函数1——tf.tile(input, multiples, name=None)input: 定义好的的张量对象列表;multiples: 不同维度的复制次数,从第一个维度开始;name: 此操作的名称(可选)。a = tf.constant([[1,2],[3,4]],name='a') 输出:<tf.Tensor: shape=(2, 2), dtype=int32, numpy=array([[1, 2],[3, 4]], dtyp原创 2021-11-30 14:07:45 · 180 阅读 · 0 评论 -
python中[-1]、[:-1]、[::-1]、[1::-1]分别代表取哪些元素?
进入python,输入以下语句:import numpy as nna=[1,2,3,4,5]b=a[-1],相当于取最后一个元素>>> b=a[-1]>>> b5c=a[:-1],返回去除掉最后一个元素的其他值>>> c=a[:-1]>>> c[1, 2, 3, 4]d=a[::-1],返回numpy的元素倒序>>> d=a[::-1]>>> d[原创 2020-06-15 17:08:32 · 4302 阅读 · 0 评论 -
如何判断张量(tensor)的维度呢?
利用python随机生成一个张量a=torch.randn(2,3,1)输出:基于上述数据可以得到以下观察,首先确定这是一个三维向量,这个可以根据最左边方括号([ )的数量来确定。那么它的形状必然是(a,b,c)的形式。看左边的第一个方括号([ )里面包含了几个元素,这里的元素是以([ ])为一组,因此a=2;再看第二个方括号([ )里包含了几个元素,这里的元素是以([ ])为一组,因此b=3;最后看第三个方括号([ )里面的元素个数,由于这是最后一维数据了,因此直接数这组括号里.原创 2020-05-13 10:50:26 · 6998 阅读 · 6 评论 -
深度学习——激活函数sigmoid
激活函数是神经网络中能够产生非线性特质的一个根源,如果没有激活函数的存在,那么整个网络只剩下线性运算,线性运算的复合还仍然线性运算,最终的效果只相当于单层的线性模型。因此,激活函数是拟合一个预期数据分布的关键。1.sigmoid函数数学表达式如下:函数图像如下所示:特征:输入:正负均可(图示为-10~+10)输出(0,1)当输入极大或极小时,可以取到实数0和实数1.缺点:1.在深度神经网络中梯度反向传递时导致梯度爆炸或梯度消失,其中梯度爆炸发生的概率非常小,而梯度消失原创 2020-05-12 17:56:22 · 2011 阅读 · 0 评论 -
交叉熵、二分类损失函数的区别——nn.CrossEntropyLoss()、nn.BCELoss()和 nn.BCEWithLogitsLoss()
import torchimport torch.nn as nnimport mathentroy=nn.CrossEntropyLoss()input=torch.Tensor([[-0.7715, -0.6205,-0.2562]])target = torch.tensor([0])print(target)tensor([0])output = entroy(input...原创 2019-11-21 17:23:59 · 3816 阅读 · 0 评论 -
Cornernet中关于解码函数(def _decode())的分析
#关于Cornernet当中解码的代码分析#def _decode( tl_heat, br_heat, tl_tag, br_tag, tl_regr, br_regr, K=100, kernel = 1, ae_threshold = 1, num_dets = 1000):#batch为batch_size,cat为训练集的类别数,height为用于预测的feat...原创 2019-10-30 17:09:34 · 458 阅读 · 0 评论 -
xml格式的数据集转coco格式的代码
原文链接在这里:https://blog.csdn.net/w113691/article/details/80817186?utm_source=blogxgwz2对部分信息进行了改动,希望能有帮助# -*- coding:utf-8 -*-# !/usr/bin/env pythonimport argparseimport jsonimport matplotlib.pyplo...转载 2019-10-30 17:05:21 · 2484 阅读 · 0 评论 -
python中关于数组的shape、size、ndim等信息
在这里,首先定义一个简单的二维数组,如下:>>> import numpy as np>>> a=np.array([[1,2],[3,4],[5,6]])>>> type(a)<type 'numpy.ndarray'>>>> a.shape(3, 2)>>> a.size6&...原创 2019-05-26 16:39:37 · 4338 阅读 · 0 评论 -
python--x.shape中(4,)与(4,1)的区别
进入python,我们输入以下语句import numpy as npa=np.array([0,1,2,3])b=np.array([[0],[1],[2],[3]])c=np.array([[0,1,2,3]])a.shape(4,)b.shape(4, 1)c.shape(1, 4)分析:a.shape说明数组a的维数是1,其中有4个元素...原创 2019-05-26 16:00:29 · 14636 阅读 · 8 评论