文章目录 一个简单的回归网络的例子 再来一个例子 官方教程上图片识别的例子 import torch import torch.nn as nn import torch.nn.functional as F import matplotlib.pyplot as plt #这个一直想学,还没学,代码从莫烦python那copy的 import torchvision import torchvision.transforms as transforms import numpy as np 很…
『PyTorch』第四弹_通过LeNet初识pytorch神经网络_上 # Author : Hellcat # Time : 2018/2/11 import torch as t import torch.nn as nn import torch.nn.functional as F class LeNet(nn.Module): def __init__(self): super(LeNet,self).__init__() self.conv1 = nn.Conv2d(3, 6, 5)…
import torch import torch.nn as nn from torch.autograd import Variable word2id = {'hello': 0, 'world': 1} # you have 2 words, and then need 5 dim each word embeds = nn.Embedding(2, 5) # we need variable, because we need use element of nn.Embedding he…