
pytorch
zzw小凡
这个作者很懒,什么都没留下…
展开
-
pytorch 使用预训练层
pytorch 使用预训练层将其他地方训练好的网络,用到新的网络里面pytorch 使用预训练层加载预训练网络加载新网络更新新网络参数加载预训练网络1.原先已经训练好一个网络 AutoEncoder_FC() 2.首先加载该网络,读取其存储的参数 3.设置一个参数集cnnpre = AutoEncoder_FC()cnnpre.load_state_dict(torch.load('au原创 2017-11-23 09:45:13 · 1662 阅读 · 1 评论 -
Pytorch Variable Tensor Numpy 之间的转换
1 tensor 转 numpya = torch.FloatTensor(3,3)print a.numpy()2 numpy 转 tensora = np.ones(5)torch.from_numpy(a)3 Variable 转 numpya = Variable(torch.FloatTensor(3,3))print a.data.numpy()3 numpy 转 Variablea...原创 2018-05-15 11:10:36 · 12517 阅读 · 0 评论 -
Pytorch tried to construct a tensor from a int , but found an item of type numpy.int32
Pytorch 需要 int 类型的数据,1.astypeimport numpy as nparr = np.array([1,2,3,4,5]).astype(int)print(arr.dtype)## int32输出的int32 并不是 pytorch 需要的类型2.np.int64()import numpy as nparr = np.int64(np....原创 2018-07-27 17:50:23 · 939 阅读 · 0 评论 -
Pytorch Multi GPU 使用
1 检测torch 是否支持gpuimport torchprint(torch.cuda.version) #查看cuda版本print(torch.cuda.is_available()) #查看pytorch 是否能用 cuda--9.0.176--True如果输出为true 就为可用,如果只有版本号,且输出为False,则需要重新装一下显卡的驱动2 前向计算device...原创 2019-06-20 16:28:38 · 1127 阅读 · 0 评论