- 博客(14)
- 资源 (1)
- 收藏
- 关注
原创 pytorch 学习(九) 一些简单的例子
#coding=utf-8import torchimport torch.nn as nnfrom torch.autograd import Variablem = nn.LeakyReLU(0.1)input = Variable(torch.randn(2))print(input)print '---' * 10print(m(input))print '--' *...
2018-07-29 21:33:14 1939
原创 python 基于BaseHTTPServer的web服务器搭建(二)
#coding=utf-8from BaseHTTPServer import HTTPServer,BaseHTTPRequestHandlerimport urllibclass MyHandler(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self...
2018-07-27 10:15:14 7563 3
原创 python web服务器(一)
# coding=utf-8'''Created on 2015-7-20@author: xhw@explain: 实现GET方法和POST方法请求'''from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandlerimport urllibclass ServerHTTP(BaseHTTPRequestHand...
2018-07-26 16:08:19 500
原创 pytorch学习(八) 给RNN使用GPU cuda()
没加cuda()前,运行时间为55s。加了cuda()后,运行时间为6s。#coding=utf-8import torchimport torch.nn as nnimport torch.utils.data as Dataimport torchvision # 数据库模块from torch.autograd import Variableimport time...
2018-07-22 20:21:21 6504 2
原创 python 字典的用法
#coding=utf-8'''字典的学习'''#创建字典info = {'name':'Lilei','age':22,'sex':'man'}print infoinfo1 = dict(name = 'Lilei',age = 22,sex = 'man')print info1#添加/修改字典元素,注意字典无序info['name'] = 'Hanmeimei...
2018-07-21 17:34:15 212
原创 pytorch 学习(八) RNN回归
#coding=utf-8import torchfrom torch import nnimport numpy as npimport matplotlib.pyplot as pltfrom torch.autograd import Variabletorch.manual_seed(1) # reproducible# Hyper ParametersTIME...
2018-07-18 20:05:35 1203
原创 pytorch 学习(八) RNN建立(分类)
#coding=utf-8import torchimport torch.nn as nnimport torch.utils.data as Dataimport torchvision # 数据库模块from torch.autograd import Variabletorch.manual_seed(1) # reproducible# Hyper P...
2018-07-18 17:47:08 818
原创 pytorch学习(七)
torch.max用法:#coding=utf-8import torchfrom torch.autograd import Variable#返回输入tensor中所有元素的最大值a = torch.randn(1, 3)print aprint torch.max(a)print '--' * 10#按维度dim 返回最大值 torch.max)(a,0) 返回每...
2018-07-18 15:18:58 194
原创 pytorch 学习(六) CNN搭建
以mnist为数据集:若原来没有数据集,把DOWNLOAD_MNIST=True。#coding=utf-8import torchimport torch.nn as nnimport torch.utils.data as Dataimport torchvision # 数据库模块import matplotlib.pyplot as pltfrom torch....
2018-07-18 11:13:33 681
原创 pytorch 学习(四)
a = torch.Tensor(2,3)print a#表示方法a[0]:表示第0行a[:,0]:表示第0列a[0][2]:表示第0行第2个元素,等价于a[0,2]a[0,-1]:第0行,最后一个元素a[:2]:表示前两行a[:2,0:2]:前两行,第0,1列a[0:1,:2]:第0行,前两列。与a[0,:2]形状不同a[torch.LongTensor([0,1])]:...
2018-07-17 19:42:42 647
原创 pytorch 学习(五)
分类:#coding=utf-8import torchimport matplotlib.pyplot as pltfrom torch.autograd import Variableimport torch.nn.functional as Fimport torch.nn as nnn_data = torch.ones(100,2)x0 = torch.normal...
2018-07-17 15:14:52 250
原创 pytorch python学习(三)
简单实现lenet-5:#coding=utf-8import torchfrom torch.autograd import Variableimport torch.nn as nnimport torch.nn.functional as Fclass Net(nn.Module): def __init__(self): super(Net,self)....
2018-07-16 11:43:20 456
原创 python pytorch学习(二)
自动微分pytorch所有网络核心是autograde自动求导包。autograde.Variable是包的核心类,它包装了张量,并且几乎支持所有的操作。可以调用.backward()方法,然后所有的梯度计算会自动完成。注意的是,通过.data属性来访问原始的张量。引用:{Variable 和 Function 是相互联系的, 并且它们构建了一个非循环的图, 编码了一个完整的计算历史信息. 每一个...
2018-07-15 20:01:38 936 1
原创 python torch学习(一)
1.torch与numpy的比较及二者之间的转换。import torchimport numpy as npnumpy_data = np.arange(15).reshape(3,5)print 'numpy_data',numpy_datatorch_data = torch.from_numpy(numpy_data)print 'torch_data',torch_data...
2018-07-15 19:32:36 26746
深度学习之PyTorch实战计算机视觉
2018-11-16
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人