上一页 1 ··· 7 8 9 10 11
摘要: """ 通常情况下,提取整个网络要比提取整个网络中的参数要慢点 """ import torch from torch.autograd import Variable import matplotlib.pyplot as plt # 数据 x = torch.unsqueeze(torch.linspace(-1, 1, 100), dim=1) y = x.pow(2) + 0.2*to... 阅读全文
posted @ 2019-01-29 19:50 车路历程 阅读(231) 评论(0) 推荐(0) 编辑
摘要: """ 以下两种搭建网络的效果是一样的,很显然第二种方法是非常简洁的 """ import torch import torch.nn.functional as F # 第一种搭建方法 class Net(torch.nn.Module): def __init__(self, n_feature, n_hidden, n_output): super(Net, se... 阅读全文
posted @ 2019-01-29 17:10 车路历程 阅读(285) 评论(0) 推荐(0) 编辑
摘要: """ pytorch中数据标签默认的数据格式是LongTensor,即64位的整数 """ import torch from torch.autograd import Variable import torch.nn.functional as F import matplotlib.pyplot as plt # 制作数据 n_data = torch.ones(100, 2) x0 ... 阅读全文
posted @ 2019-01-29 17:01 车路历程 阅读(219) 评论(0) 推荐(0) 编辑
摘要: """ 在pytorch中只有Variable可以参与网络的训练 """ import torch from torch.autograd import Variable import torch.nn.functional as F import matplotlib.pyplot as plt x = torch.unsqueeze(torch.linspace(-1, 1, 100), ... 阅读全文
posted @ 2019-01-29 12:26 车路历程 阅读(571) 评论(0) 推荐(0) 编辑
摘要: """ Variable为tensor数据构建计算图,便于网络的运算 """ import torch from torch.autograd import Variable tensor = torch.FloatTensor([[1,2],[3,4]]) # 创建一个tensor类型的数据 variable = Variable(tensor, requires_gr... 阅读全文
posted @ 2019-01-29 11:43 车路历程 阅读(1965) 评论(0) 推荐(0) 编辑
摘要: """ pytorch相当于神经网络中的numpy,它是以tensor的形式表示 """ import torch import numpy as np # convert numpy to tensor or vise versa np_data = np.arange(6).reshape((2, 3)) torch_data = torch.from_numpy(np_data) #nu... 阅读全文
posted @ 2019-01-29 11:36 车路历程 阅读(7537) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11