
pytorch学习笔记
沃·夏澈德
今天的明天是后天的昨天。----茨鲍勒·程德
展开
-
torch 查看网络参数量
from torchsummary import summary a = summary(eegnet,input_size=(a,b,c),batch_size=-1)原创 2022-02-22 10:43:04 · 459 阅读 · 0 评论 -
pytorch的shuffle功能
import torch # 原数据 x = torch.arange(0, 10) print(x) # 生成随机索引 shuffle_index=torch.randperm(10) print(x[shuffle_index])原创 2021-11-11 20:04:41 · 2988 阅读 · 0 评论 -
pytorch 中的tensor.T 与tensor.data
tensor.T 是 tensor.data的转置原创 2021-11-11 16:54:38 · 1999 阅读 · 0 评论 -
pytorch学习笔记,cnn与gpu加速
cnn代码,警告见gpu版修正,版本问题。 import torch import torch.nn as nn import torch.utils.data as Data import torchvision # 数据库模块 import matplotlib.pyplot as plt import logging logger = logging.Logger(None) torch.manual_seed(1) # reproducible # Hyper Param原创 2021-07-04 10:19:52 · 761 阅读 · 0 评论 -
pytorch学习笔记,回归和分类
回归 import torch import matplotlib.pyplot as plt x = torch.unsqueeze(torch.linspace(-1, 1, 100), dim=1) # x data (tensor), shape=(100, 1) y = x.pow(2) + 0.2*torch.rand(x.size()) # noisy y data (tensor), shape=(100, 1) # 画图 plt.scatter(x原创 2021-07-03 20:24:32 · 231 阅读 · 1 评论 -
pytorch学习笔记1,变量与激活函数
import torch from torch.autograd import Variable # torch 中 Variable 模块 # 先生鸡蛋 tensor = torch.FloatTensor([[1,2],[3,4]]) # 把鸡蛋放到篮子里, requires_grad是参不参与误差反向传播, 要不要计算梯度 variable = Variable(tensor, requires_grad=True) print(tensor) """ 1 2 3 4 [torch.Fl.原创 2021-07-03 19:40:20 · 316 阅读 · 0 评论 -
pytorch学习笔记0,gpu测试与torch
测试gpu代码,网上找的。 import torch import time print(torch.__version__) # 返回pytorch的版本 print(torch.cuda.is_available()) # 当CUDA可用时返回True,其实到这步基本已经确定了gpu是没问题的了。后面只是计算时间作对比而已。 a = torch.randn(10000, 1000) # 返回10000行1000列的张量矩阵 b = torch.rand原创 2021-07-03 18:32:50 · 526 阅读 · 0 评论