
Pytorch
YahamaTarGe
这个作者很懒,什么都没留下…
展开
-
RuntimeError: ONNX symbolic expected a constant value in the trace
pth 模型转 onnx时出错参考 up3 = F.interpolate(output3, size=[output2.size(2), output2.size(3)], mode="nearest") # errorup3 = F.interpolate(output3, size=[32, 32], mode="nearest") ...原创 2019-10-19 11:12:59 · 620 阅读 · 0 评论 -
pytorch tensor筛选满足条件的行或列(使用与或)
import torchx = torch.linspace(1, 8, steps=8).view(4, 2)print(x)area1=(x[:,0]>5.5)&(x[:,1]>5.5)c=x[:,0]*x[:,1]area2=c>25area=area1|area2print(x[area])if 0:# index=torch.max(area,...转载 2019-01-24 11:32:24 · 18172 阅读 · 2 评论 -
pytorch 正确的测试时间的代码 torch.cuda.synchronize()
start = time.time()result = model(input)end = time.time()torch.cuda.synchronize()start = time.time()result = model(input)torch.cuda.synchronize()end = time.time()一共上述两种测试时间的方式,正确的方式是第二种,为什么是...转载 2019-06-11 15:26:16 · 3405 阅读 · 1 评论 -
pytorch torchvision.transforms.Normalize()中的mean和std参数---解惑
torchvision.transforms.Normalize()中的mean和std参数做什么用呢?疑问1:按照我的理解,归一化就是要把图片3个通道中的数据整理到[-1, 1]区间。x = (x - mean(x))/stddev(x)只要输入数据集x确定了,mean(x)和stddev(x)也就是确定的数值了,为什么Normalize()函数还需要输入mean和std的数值呢?疑问...转载 2019-06-26 18:21:44 · 2531 阅读 · 1 评论 -
计算数据集中图像均值
import osimport numpy as npimport cv2 ims_path = r'E:\Datasets/' # Path to Images#ims_list = os.listdir(ims_path)g = os.walk(ims_path)ims_list = ['%s\\%s' % (i[0], j) for i in g if i[0].ends...原创 2019-06-26 18:42:56 · 871 阅读 · 4 评论 -
Torchvision transforms 总结
转载自 https://blog.youkuaiyun.com/Hansry/article/details/84071316一.torchvision.transformsTransfoms 是很常用的图片变换方式,可以通过compose将各个变换串联起来**1. class torchvision.transforms.Compose (transforms) **这个类将多个变换方式结合在一起...转载 2019-06-24 11:37:11 · 1961 阅读 · 0 评论