def forward(self, input):
x = F.elu(self.conv1(input))
x = F.elu(self.conv2(x))
x = F.elu(self.conv3(x))
# Next flatten the output to be batched into LSTM layers
# The shape of x is batch_size, channels, height, width
x = self.pre_lstm_bn(x)
x = torch.transpose(x, 1, 3)
x = torch.transpose(x, 1, 2)
x = x.contiguous()
x = x.view(x.size(0), self.batch, self.hidden_dim)
x, hidden = self.lstm(x, (self.hidden_state, self.cell_state))
self.hidden_state, self.cell_state = hidden
x = torch.transpose(x, 2, 1)
x = x.contiguous()
x = x.view(x.size(0), self.hidden_dim, self.height, self.width)
x = self.lstm_batch_norm(x)
x = F.elu(self.conv4(x))
x = F.elu(self.conv5(x))
logit = self.move_conv(x)
logit = logit.view(logit.size(0), -1)
x = self.value_conv(x)
x = x.view(x.size(0), self.hidden_dim, self.batch)
x = F.max_pool1d(x, self.batch)
x = x.squeeze()
val = self.value_linear(x)
return val, logit
评论列表
文章目录