本文共 2839 字,大约阅读时间需要 9 分钟。
PyTorch 模型实战系列学习笔记
本周学习内容:
环境配置:
CNN 模型实现
def __init__(self): super(CNN, self).__init__() self.conv1 = nn.Sequential( nn.Conv2d(1, 16, kernel_size=5, stride=1, padding=2), nn.ReLU(), nn.MaxPool2d(kernel_size=2) ) self.conv2 = nn.Sequential( nn.Conv2d(16, 32, kernel_size=5, stride=1, padding=2), nn.ReLU(), nn.MaxPool2d(kernel_size=2) ) self.out = nn.Linear(32*7*7, 10)
模型功能
训练过程
[7,2,1,0,4,1,4,9,5,9]
RNN 类ification 模型
def forward(self, x): r_out, (h_n, h_c) = self.rnn(x, None) return self.out(r_out[:, -1, :])
模型架构
训练过程
[7,2,1,0,4,1,4,9,8,9]
RNN 回归 模型
def forward(self, x, h_state): r_out, h_state = self.rnn(x, h_state) return self.out(r_out[:, -1, :]), h_state
模型特点
训练过程
自编码器 模型
编码器部分
self.encoder = nn.Sequential( nn.Linear(28*28, 128), nn.Tanh(), nn.Linear(128, 64), nn.Tanh(), nn.Linear(64, 12), nn.Tanh(), nn.Linear(12, 3))
解码器部分
self.decoder = nn.Sequential( nn.Linear(3, 12), nn.Tanh(), nn.Linear(12, 64), nn.Tanh(), nn.Linear(64, 128), nn.Tanh(), nn.Linear(128, 28*28), nn.Sigmoid())
学习目的
训练过程
DQN 模型结构
class Net(nn.Module): def __init__(self): self.fc1 = nn.Linear(N_STATES, 50) self.fc1.weight.data.normal_(0, 0.1) self.out = nn.Linear(50, N_ACTIONS) self.out.weight.data.normal_(0, 0.1) def forward(self, x): x = self.fc1(x) x = F.relu(x) return self.out(x)
训练过程
GAN 模型架构
G = nn.Sequential( nn.Linear(N_IDEAS, 128), nn.ReLU(), nn.Linear(128, ART_COMPONENTS))D = nn.Sequential( nn.Linear(ART_COMPONENTS, 128), nn.ReLU(), nn.Linear(128, 1), nn.Sigmoid())
训练过程
以上就是本周学习内容的各个实战报告。
转载地址:http://pwdhz.baihongyu.com/