
torch
文章平均质量分 58
飞龙在天max
这个作者很懒,什么都没留下…
展开
-
pytorch函数详解
pytorch函数详解在typora这里写之后复制到简书上1. torchvision1.1 transforms.Compose(transforms)把几个转换组合example:from PIL import Imaget_tran = []t_tran.append(transforms.Resize(image_size)) # 64t_tran.append(transforms.CenterCrop(image_size))img = Image.open(dat原创 2021-05-19 09:09:00 · 1976 阅读 · 1 评论 -
pytorch 分布式 gpu
2. 分布式gpu两种方法,第一是 nn.DataParallel 使用简单,第二是 torch.distributed,推荐使用第二个。注意:自己定义的模型属性方法,并行化后无法使用,torch.distributed 使用 model = model.module 即可解决,但是 nn.DataParallel 使用之后就会变成非并行。os.environ[‘CUDA_VISIBLE_DEVICES’] = ‘2,3’ 需要放到第一次使用 torch 之前,否则不会起作用。torch.dis原创 2021-03-20 23:07:40 · 439 阅读 · 0 评论 -
pytorch Kfold数据集划分
今天想使用K折方法进行训练,发现 pytorch dataloader 中没有需要的一键操作的代码,我自己写了一个。首先得到数据量,然后使用 sklearn.model_selection 的 KFold 方法划分数据索引,最后使用 torch.utils.data.dataset.Subset 方法得到划分后的子数据集。代码思路如下。import torchfrom sklearn.model_selection import KFolddata_induce = np.arange(0, da原创 2021-01-29 16:01:47 · 3956 阅读 · 2 评论 -
pytorch visualizing
visualizingPyTorch integrates with TensorBoard, a tool designed for visualizing the results of neural network training runs.In this tutorial, we’ll learn how to:Read in data and with appropriate t...翻译 2019-11-21 11:39:25 · 187 阅读 · 0 评论 -
建立CNN模型1
建立CNN模型1.import 相关模组sequentialConv2DMaxPooling2DDropout2. 用Sequential开始建模3. convolution and pooling3.1 卷积层一个滤镜(矩阵),把本来的图片进行转换,转换之后可以代表之前的一些特征。(放大本来的特征)3.2 池化层精简一点?Conv2d 和 pooling 交替使用r...原创 2019-11-18 10:31:07 · 867 阅读 · 0 评论 -
torch函数详解
import torchx = torch.randn(2,1,7,3)conv = torch.nn.conv2d(1,8,(2,3))res = conv(x)print(res.shape) # shape = (2, 8, 6, 1)输入x[ batch_size, channels, height_1, width_1 ]batch_size 一个batch中...原创 2019-11-18 10:16:21 · 1038 阅读 · 0 评论 -
Pytorch两层神经网络
文章目录Pytorch: optimPytorch: 自定义 nn ModulesPytorch: optim这一次我们不用手动更新model的weights,而是使用optim这个包来帮助我们更新参数。optim这个package提供了各种不同的model优化方法,包括SGD+momentum,RMSProp,Adamimport torchN, D_in, H, D_out = 6...原创 2019-10-31 20:08:44 · 542 阅读 · 0 评论