
莫烦python
喵纳德
热爱生命
展开
-
3.6 Optimizer优化器
文章目录import torchimport torch.utils.data as Dataimport torch.nn.functional as Fimport matplotlib.pyplot as plt# torch.manual_seed(1) # 保证随机数不变LR = 0.01BATCH_SIZE = 32EPOCH = 12# fake dat...原创 2020-01-01 19:37:55 · 423 阅读 · 0 评论 -
3.5 批训练数据
文章目录import torchimport torch.utils.data as Datatorch.manual_seed(1) # reproducibleBATCH_SIZE = 5# BATCH_SIZE = 8x = torch.linspace(1, 10, 10) # this is x data (torch tensor)y = torc...原创 2020-01-01 17:34:33 · 264 阅读 · 0 评论 -
3.4 保存和提取神经网络方法(两种方法)
文章目录import torchimport torch.nn.functional as F # 激励函数都在这import matplotlib.pyplot as plttorch.manual_seed(1) # reproducible# 假数据x = torch.unsqueeze(torch.linspace(-1, 1, 100), dim=1) #...原创 2020-01-01 17:04:08 · 607 阅读 · 0 评论 -
3.3 快速搭建神经网络(两种方法)
文章目录import torchimport torch.nn.functional as F # 激励函数都在这import matplotlib.pyplot as plt# method1class Net(torch.nn.Module): def __init__(self, n_feature, n_hidden, n_output): su...原创 2020-01-01 16:32:11 · 355 阅读 · 0 评论 -
分类
文章目录课程链接import torchimport torch.nn.functional as F # 激励函数都在这import matplotlib.pyplot as plt# 假数据n_data = torch.ones(100, 2) # 数据的基本形态# normal离散正态分布,均值和标准差x0 = torch.normal(2*n_da...原创 2020-01-01 16:30:01 · 230 阅读 · 0 评论 -
回归
文章目录生成数据定义一个神经网络训练课程链接生成数据import torchimport matplotlib.pyplot as plt#linspace(start, end, steps)表示在[start, end]中均分为stepsg个的tensor。unsqueeze是在dim维度上扩充数据维度x = torch.unsqueeze(torch.linspace(-1, ...原创 2020-01-01 15:23:47 · 201 阅读 · 0 评论