随笔分类 -  深度学习~pytorch

pytorch调用的一些代码解读
该文被密码保护。
posted @ 2021-04-12 13:38 皮卡皮卡妞 阅读(0) 评论(0) 推荐(0) 编辑
摘要:import time from options.train_options import TrainOptions from data import create_dataset from models import create_model from util.visualizer import 阅读全文
posted @ 2021-03-31 13:15 皮卡皮卡妞 阅读(266) 评论(0) 推荐(0) 编辑
摘要:将1*(1024*128)降维为(1*1024),将(1*1024)降维为(1*512); 将(1*512)升维为(1*1024),将(1*1024)升维为1*(1024*128); self.fc = nn.Sequential( nn.Linear(1024*128, 1024), nn.Lin 阅读全文
posted @ 2021-03-29 11:21 皮卡皮卡妞 阅读(821) 评论(0) 推荐(0) 编辑
摘要:将x4平铺成一维向量,得到x5; 将x5压缩成和x4shape一样,得到x6 x5 = x4.view(x4.size(0), -1) x6 = x5.detach().view_as(x4) 阅读全文
posted @ 2021-03-29 11:18 皮卡皮卡妞 阅读(191) 评论(0) 推荐(0) 编辑
摘要:w_size = 512 h_size = 256 sub_input_label = torch.zeros([input_label.shape[0],input_label.shape[1],h_size,w_size], dtype=torch.float32,device=input_la 阅读全文
posted @ 2021-03-05 15:35 皮卡皮卡妞 阅读(67) 评论(0) 推荐(0) 编辑
摘要:import torch # 正向传播时:开启自动求导的异常侦测 torch.autograd.set_detect_anomaly(True) # 反向传播时:在求导时开启侦测 with torch.autograd.detect_anomaly(): loss.backward() 阅读全文
posted @ 2021-03-05 09:57 皮卡皮卡妞 阅读(13605) 评论(0) 推荐(2) 编辑
摘要:错误: RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [3, 32, 1, 1 阅读全文
posted @ 2021-03-05 09:55 皮卡皮卡妞 阅读(418) 评论(0) 推荐(0) 编辑
摘要:def mutil_max_loss_two(self,R_loss,O_loss): if R_loss>O_loss: O_loss=R_loss return O_loss def mutil_max_loss_three(self,M_loss,glass_loss,O_loss): if 阅读全文
posted @ 2021-02-22 09:46 皮卡皮卡妞 阅读(190) 评论(0) 推荐(0) 编辑
摘要:new_mask_image = torch.zeros([inst_map.shape[0],inst_map.shape[1],inst_map.shape[2],inst_map.shape[3]], dtype=torch.float32,device=inst_map.device) fo 阅读全文
posted @ 2021-02-22 09:43 皮卡皮卡妞 阅读(3107) 评论(0) 推荐(0) 编辑
摘要:def tensor2im(image_tensor, imtype=np.uint8, normalize=True): image_numpy = image_tensor.cpu().float().detach().numpy() if normalize: image_numpy = (i 阅读全文
posted @ 2021-02-22 09:39 皮卡皮卡妞 阅读(1288) 评论(0) 推荐(0) 编辑
摘要:def tensor2im(image_tensor, imtype=np.uint8, normalize=True): image_numpy = image_tensor.cpu().float().detach().numpy() if normalize: image_numpy = (i 阅读全文
posted @ 2021-02-22 09:36 皮卡皮卡妞 阅读(1119) 评论(0) 推荐(0) 编辑
摘要:一个输入: input_tensor = torch.randn([1, 3, 256, 512]) print ("Exporting to ONNX: ", onnx_save_name) torch_onnx_out = torch.onnx.export(model, input_tenso 阅读全文
posted @ 2020-11-04 14:01 皮卡皮卡妞 阅读(5666) 评论(0) 推荐(0) 编辑
摘要:打印pytorch每层参数。 采用的是直接在层中加入txt的写入。需要修改的文件位置:./site-packages/torch/nn/modules/ Conv2D v = F.conv2d(input, self.weight, self.bias, self.stride,self.paddi 阅读全文
posted @ 2020-10-28 11:33 皮卡皮卡妞 阅读(2169) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-10-28 10:47 皮卡皮卡妞 阅读(2444) 评论(0) 推荐(0) 编辑
摘要:下载地址为: https://download.pytorch.org/whl/torch_stable.html 阅读全文
posted @ 2020-10-23 14:42 皮卡皮卡妞 阅读(435) 评论(0) 推荐(0) 编辑
该文被密码保护。
posted @ 2020-10-13 10:11 皮卡皮卡妞 阅读(228) 评论(0) 推荐(0) 编辑
摘要:def tensor2im(image_tensor, imtype=np.uint8, normalize=True): image_numpy = image_tensor.cpu().float().detach().numpy() if normalize: image_numpy = (i 阅读全文
posted @ 2020-10-13 10:02 皮卡皮卡妞 阅读(575) 评论(0) 推荐(0) 编辑
摘要:报错: 修改: model.module.optimizer_G.zero_grad() loss_G.backward() model.module.optimizer_G.step() 为: model.module.optimizer_G.zero_grad() loss_G.backward 阅读全文
posted @ 2020-09-25 15:47 皮卡皮卡妞 阅读(2966) 评论(0) 推荐(0) 编辑
摘要:model_dict = torch.load(save_path) fp = open('model_parameter.bin', 'wb') weight_count = 0 num=1 for k, v in model_dict.items(): print(k,num) num=num+ 阅读全文
posted @ 2020-09-25 15:13 皮卡皮卡妞 阅读(5252) 评论(0) 推荐(0) 编辑
摘要:pytorch+python 错误: 纠正: self.trace, _ = torch.jit.get_trace_graph(self.model, args=(self.x,)) 为: self.trace, _ = torch.jit._get_trace_graph(self.model, 阅读全文
posted @ 2020-09-25 15:09 皮卡皮卡妞 阅读(3169) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示