- 博客(5)
- 收藏
- 关注
原创 Python中如何将float浮点型列表转换为int整型列表
字符串,整型,浮点型等类型之间的转换可以举一反三,此处举例将浮点型转为整型的例子:下面展示一些 内联代码片。1. map(int, list)a = [0.0567, 9.2345, 8.1986, 4.3333];a_int = list(map(int, a))2.for 循环a_int = [int(a) for a in a]或者:a_int = [round(a) for a in a]或者:import matha_int = [math.ceil(a) for a
2021-07-08 02:44:42
18253
1
原创 基于CUSUM算法的异常检测(Part 1)
基于CUSUM算法的异常检测(Part 1)基于文章"The CUSUM Algorithm - a small review Poerre Granjon"的代码复现(待完善)Algorithm4代码// An highlighted blockimport numpy as npimport matplotlib.pyplot as plt#Create a synthetic Guassian data set to test#x = np.concatenate([np.random.
2021-06-22 06:13:30
2827
4
原创 torchvision.transforms系列函数
torchvision.transforms系列函数(一)一、torchvision.transforms.Resize()函数的作用将输入的图像(PIL Image模块)resize为给定参数size=(h,w)的模样,若给定size 是一个整数,且原图像h>w,那么新图像的大小被rescale为(size*height/width, size)torchvision.transforms.ToTensor()本函数目的是将PIL Image/numpy.narray数据类型转变为tor
2020-09-29 10:47:33
1395
原创 关于python中.item()的用法
关于python中.item()的用法本白在搜索引擎里面搜item出来的大多全是items()遍历,或者标题是item(),点进去内容却还是在讲items()。所以我还是打算记录一下。官方小册子链接在此????作用:取出单元素张量的元素值并返回该值,保持原元素类型不变。,即:原张量元素为整形,则返回整形,原张量元素为浮点型则返回浮点型,etc.x[1,1] V.S. X.item():下面的例子我当时是想观察一下,直接用[1,1]取出元素与使用.item()取出元素有什么区别。我感觉是显示精度
2020-09-18 10:39:30
80444
9
原创 Pytorch中rand,randn, random以及normal的区别
Pytorch中rand,randn, random以及normal的区别torch.rand()torch.randn()torch.normal()torch.randperm()torch.randint()torch.rand()torch.rand(sizes, out=None)产生一个服从均匀分布的张量,张量内的数据包含从区间[0,1)的随机数。参数size是一个整数序列,用于定义张量大小。torch.randn()torch.randn(sizes, out=None)产生一个服
2020-09-16 15:53:47
6894
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人