-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dimension Error in Inference #10
Comments
I got the same error as yours before, the error occurred just because the codes should run with older version of pytorch (at least before 0.4.0, maybe 0.3.1 I guess...You have to notice that the last modification of the project is 8 months ago ) , and then it fixed when I changed pytorch version. |
Yep this is relative to the version of Pytorch. self.gru = nn.GRUCell(32, self.gru_hidden_size) def forward(self, inputs):
x, input_inst, (tx, hx, cx) = inputs
# Get the image representation
x = F.relu(self.conv1(x))
x = F.relu(self.conv2(x))
x_image_rep = F.relu(self.conv3(x))
# Get the instruction representation
encoder_hidden = torch.zeros(1, self.gru_hidden_size) # seq_len=1
for i in range(input_inst.data.size(1)):
word_embedding = self.embedding(input_inst[0, i]).unsqueeze(0)
#print(word_embedding.shape) # [1, 32]
encoder_hidden = self.gru(word_embedding, encoder_hidden)
x_instr_rep = encoder_hidden.view(-1, encoder_hidden.size(1))
# print(x_instr_rep.shape)
# Get the attention vector from the instruction representation
x_attention = torch.sigmoid(self.attn_linear(x_instr_rep))
# Gated-Attention
x_attention = x_attention.unsqueeze(2).unsqueeze(3)
x_attention = x_attention.expand(1, 64, 8, 17)
assert x_image_rep.size() == x_attention.size()
x = x_image_rep*x_attention
x = x.view(x.size(0), -1)
# A3C-LSTM
x = F.relu(self.linear(x))
hx, cx = self.lstm(x, (hx, cx))
time_emb = self.time_emb_layer(tx)
x = torch.cat((hx, time_emb.view(-1, self.time_emb_dim)), 1)
return self.critic_linear(x), self.actor_linear(x), (hx, cx) |
@egg-west File "a3c_main.py", line 115, in <module>
torch.load(args.load, map_location=lambda storage, loc: storage))
File "/home/yunlian/virtualenvs/python3.7/lib/python3.7/site-packages/torch/nn/modules/module.py", line 839, in load_state_dict
self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for A3C_LSTM_GA:
Missing key(s) in state_dict: "gru.weight_ih", "gru.weight_hh", "gru.bias_ih", "gru.bias_hh".
Unexpected key(s) in state_dict: "gru.weight_ih_l0", "gru.weight_hh_l0", "gru.bias_ih_l0", "gru.bias_hh_l0". |
Hi
I was trying to run ' python a3c_main.py --evaluate 2 --load saved/pretrained_model' to run inference using the pre-trained model. However, I faced the following dimension error without changing the code:
Any leads would be appreciated
The text was updated successfully, but these errors were encountered: