随笔分类 -  Pytorch

摘要:Background 有两个相同的图像数据集,仅图像的分辨率不同(如一批为128一批为64),数据集中的图像一一对应, 为两个数据集分别设置两个Dataloader,现在想要在加载batch时得到一一对应且乱序的图像。 如果仅在Dataloader中设置shuffle=True,得到的两个batch 阅读全文
posted @ 2020-09-25 18:06 Junzhao 阅读(320) 评论(0) 推荐(0)
摘要:FID(Frechet Inception Distance score) 是计算真实图像和生成图像的特征向量之间距离的一种度量。 首先用预训练的Inception v3分别生成真实图像(real images)和生成图像(synthetic images)的特征向量(默认dim=2048) 然后用Frechet 距离(又称 Wasserstein-2 距离)计算得到的两个特征向量分布,公式如下 ... 阅读全文
posted @ 2020-09-02 17:43 Junzhao 阅读(1379) 评论(0) 推荐(0)
摘要:1. 导入库: import torch.distributed as dist from torch.utils.data.distributed import DistributedSampler 2. 进程初始化: parser = argparse.ArgumentParser() pars 阅读全文
posted @ 2020-08-20 16:44 Junzhao 阅读(5386) 评论(0) 推荐(0)
摘要:1 from torch.utils.data import DataLoader 2 from torchvision import datasets 3 from PIL import Image as img 4 5 dataPath = './data/imgs/' 6 7 dataset 阅读全文
posted @ 2020-03-17 20:44 Junzhao 阅读(430) 评论(0) 推荐(0)
摘要:转置卷积实际是根据输入卷积核和输入特征图生成中间卷积核和特征图,再进行卷积操作 输入的卷积核kernel 大小 Size = size 步长 Stride = stride 填充 Padding = padding 输入特征图 H W 中间卷积核kernel' 大小 Size' = size 步长 阅读全文
posted @ 2020-03-16 10:54 Junzhao 阅读(790) 评论(0) 推荐(0)
摘要:a=torch.rand(32,1) a.expend(imgs.size()) >>>RuntimeError: The expanded size of the tensor (256) must match the existing size (32) at non-singleton dim 阅读全文
posted @ 2020-02-26 20:03 Junzhao 阅读(2670) 评论(0) 推荐(0)
摘要:nn.MSELoss()得到的是平均到像素的loss nn.MSELoss(size_average=False)得到整个batch所有像素loss和 MSELoss(size_average=False).div(batch_size)得到平均图像loss a=torch.Tensor([[1,1 阅读全文
posted @ 2020-02-25 16:44 Junzhao 阅读(1937) 评论(0) 推荐(0)
摘要:https://www.cnblogs.com/wanghui-garcia/p/10895397.html 阅读全文
posted @ 2020-02-21 11:15 Junzhao 阅读(114) 评论(0) 推荐(0)
摘要:ANTsPy主页:https://github.com/ANTsX/ANTsPy ANTsPy官方文档:https://antspyx.readthedocs.io/_/downloads/en/latest/pdf/ 配准ants.registration() import os import a 阅读全文
posted @ 2020-02-14 17:24 Junzhao 阅读(5046) 评论(9) 推荐(0)
摘要:当训练数据量不能被batch_size大小整除时,余下的部分会作为最后一批 保存生成图像时,应指定生成数量为batch_size,而不是dataloader中的img.size(0) 应为z = Variable(torch.randn(batch_size, z_dimension)).cuda( 阅读全文
posted @ 2020-02-12 18:24 Junzhao 阅读(590) 评论(0) 推荐(0)
摘要:https://blog.csdn.net/bigbennyguo/article/details/87956434 from torch.utils.tensorborad import SummaryWriter from tensorboardX import SummaryWriter 阅读全文
posted @ 2020-01-12 14:17 Junzhao 阅读(607) 评论(0) 推荐(0)
摘要:利用torchvision.transforms 阅读全文
posted @ 2020-01-07 19:34 Junzhao 阅读(477) 评论(0) 推荐(0)
摘要:构建数据集: 网络搭建: class nn(nn.Module): def __init__(self): super(nn, self).__init__() self.nets = nn.Sequential( # 网络细节 # 针对单元(图像···) ) def forward(self, x 阅读全文
posted @ 2019-11-15 20:50 Junzhao 阅读(204) 评论(0) 推荐(0)
摘要:num_workers通过影响数据加载速度,从而影响训练速度 在调整num_workers的过程中,发现训练速度并没有变化 原因在于: num_workers是加载数据(batch)的线程数目 当加载batch的时间 < 数据训练的时间 GPU每次训练完都可以直接从CPU中取到next batch的 阅读全文
posted @ 2019-11-15 20:00 Junzhao 阅读(17569) 评论(0) 推荐(1)
摘要:1. if__name__=='__main__': RuntimeError:... if __name__ == '__main__': freeze_support() ... Python创建子进程时,子进程会导入脚本模块,因此需要用if__name__=='__main__':将创建子进程 阅读全文
posted @ 2019-11-14 15:15 Junzhao 阅读(113) 评论(0) 推荐(0)
摘要:1. numpy.genfromtxt(path, delimiter=',', dtype=str, skip_header=1) 将数据从csv导入array *类型为string 若数据为图像,还需对图像进行处理(增广) string--split()--list--np.array()--n 阅读全文
posted @ 2019-11-12 21:12 Junzhao 阅读(524) 评论(0) 推荐(0)