Hi,
I am currently implementing a DRQN network which works correctly, however I want to unroll the LSTM network for a specified amount of steps, how do I do this in pytorch? Could someone provide some insight?
I have followed this tutorial, but there is no mention of unrolling:
https://pytorch.org/tutorials/beginner/nlp/sequence_models_tutorial.html
class DRQNBody(nn.Module): def __init__(self, in_channels=4): super(DRQNBody, self).__init__() self.feature_dim = 512 self.rnn_input_dim = 7*7*64 self.batch_size = -1 self.conv1 = layer_init(nn.Conv2d(in_channels, 32, kernel_size=8, stride=4)) self.conv2 = layer_init(nn.Conv2d(32, 64, kernel_size=4, stride=2)) self.conv3 = layer_init(nn.Conv2d(64, 64, kernel_size=3, stride=1)) self.lstm = nn.LSTM(self.rnn_input_dim, self.feature_dim , num_layers = 4) self.hidden = self.init_hidden() def forward(self, x): y = F.relu(self.conv1(x)) y = F.relu(self.conv2(y)) y = F.relu(self.conv3(y)) y = y.view(y.size(0), -1) # flattening y = y.view(1, self.batch_size, self.rnn_input_dim) # Adding dimention output, self.hidden = self.lstm(y, self.hidden) y = output y = torch.squeeze(y,1) return y