![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Pytorch
-Wave
这个作者很懒,什么都没留下…
展开
-
Pytorch实现GAN之生成手写数字图片
1.导入所需库import torchimport torch.optim as optimimport torch.nn as nnimport torch.nn.functional as Fimport numpy as npimport matplotlib.pyplot as pltimport torchvisionimport torchvision.transforms as transforms2. 训练集# mini_batch sizemb_size=64#t原创 2020-06-10 16:33:04 · 2182 阅读 · 1 评论 -
莫烦_Pytroch教程_保存提取
我们用回归的神经网络举例实现保存提取。import torchtorch.manual_seed(1)x=torch.unsqueeze(torch.linspace(-1,1,100),dim=1)y=x.pow(2)+0.2*torch.rand(x.size())def save(): net1=torch.nn.Sequential( torch.nn.Linear(1,10), torch.nn.ReLU(), torch.nn原创 2020-06-06 16:20:07 · 116 阅读 · 0 评论 -
莫烦_Pytorch教程_分类(Classification)和快速搭建法则
1.建立数据集torch.normal(means, std, out=None)返回一个张量,包含从给定参数means,std的离散正态分布中抽取随机数。means (Tensor) – 均值std (Tensor) – 标准差out (Tensor) – 可选的输出张量import torchimport matplotlib.pyplot as plt# fake data# y0,y1分别为x0,x1的labeln_data=torch.ones(100,2)x0 = t原创 2020-06-06 15:28:48 · 197 阅读 · 0 评论 -
莫烦_Pytorch教程_关系拟合(回归)
1. 导入包import torchfrom torch.autograd import Variableimport matplotlib.pyplot as pltimport torch.nn.functional as F2. 建立数据集torch.unsqueeze():扩充数据维度,在0起的指定位置N加上维数为1的维度torch.squeeze(): 维度压缩,在0起的指定位置N,去掉维数为1的的维度torch.linspace() 返回一个一维的tensor(张量),原创 2020-06-03 16:03:08 · 204 阅读 · 0 评论 -
Pytorch_From_Youtube
P6 tensordd=[[1,2,3], [2,4,6], [3,5,7]]t=torch.tensor(dd)print(t)print(type(t))print(t.shape)In pytorch, size and shape are the same thingThe shape of tensor also reveals the rank of tesnor.print(t.reshape(1,9))P7 CNN Tensor Shape Expl原创 2020-06-03 14:33:26 · 180 阅读 · 0 评论 -
Pytorch_CNN识别mnist手写数字 (神经网络中的Hello World)
完整代码注意:若project中没有mnist文件,则DOWNLOAD_MNIST = Ture;下载完成后再变为False.import torchimport torch.nn as nnfrom torch.autograd import Variableimport torch.utils.data as Dataimport torchvision # 数据库模块import matplotlib.pyplot as plttorch.manual_seed(1) # re原创 2020-05-27 20:31:08 · 160 阅读 · 0 评论 -
Pytorch教程_Variable变量
Variable变量part1import torchfrom torch.autograd import Variabletensor=torch.FloatTensor([[1,2],[3,4]])variable=Variable(tensor, requires_grad=True)print(tensor)print(variable)part2import torchfrom torch.autograd import Variabletensor=torch.F原创 2020-05-27 12:35:59 · 190 阅读 · 0 评论 -
在Anaconda中下载包到虚拟环境中
我开始是用pip install进行安装,但是速度慢,容易出错。进入我的虚拟环境,名为pytorchactivate pytorch下载pip install matplotlib -i https://pypi.doubanio.com/simple原创 2020-05-25 13:53:14 · 769 阅读 · 0 评论 -
Pytorch_神经网络 2.1Numpy和torch对比
1.numpy的array和torch表示的对比import torchimport numpy as npnp_data=np.arange(6).reshape((2,3))torch_data=torch.from_numpy(np_data)tensor2array=torch_data.numpy()print( '\nnumpy',np_data, '\...原创 2020-04-27 22:40:18 · 145 阅读 · 0 评论 -
关于Anaonda官网安装慢的问题
1.镜像网站下载https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/2.验证打开anaconda promote如果显示base则安装成功3.用命令配置环境conda create -n pytorch python=3.6原创 2020-04-27 22:04:38 · 185 阅读 · 0 评论 -
Pytorch安装
1.简单方法https://www.cnblogs.com/fanchenxiaojia/p/11208955.htmlhttps://blog.csdn.net/cuixing001/article/details/819521162.关于cudahttps://blog.csdn.net/qq_23013309/article/details/103965619?depth_1-utm...原创 2020-04-27 18:33:11 · 135 阅读 · 0 评论