(webaskb) ➜ WebAsKB git:(master) ✗ python webaskb_run.py train_ptrnet
load the GloVe dataset sample that matches to our vocabulary
loaded:400000
initialize the vocabulary words that are not in Glove to the 0 vector
done!
Read 27734 sentence pairs
Counting words...
total number of pair:24708
Read 3480 sentence pairs
Counting words...
total number of pair:3480
Traceback (most recent call last):
File "webaskb_run.py", line 30, in <module>
ptrnet.train()
File "/home/vimos/Data/git/QA/WebAsKB/webaskb_ptrnet.py", line 100, in train
self.net.run_training()
File "/home/vimos/Data/git/QA/WebAsKB/Net/run.py", line 55, in run_training
DO_TECHER_FORCING=teacher_forcing)
File "/home/vimos/Data/git/QA/WebAsKB/Models/webaskb_ptrnet.py", line 192, in forward
encoder_output, encoder_hidden = self.encoder(input_variable[ei], encoder_hidden)
File "/home/vimos/anaconda3/envs/webaskb/lib/python3.6/site-packages/torch/nn/modules/module.py", line 357, in __call__
result = self.forward(*input, **kwargs)
File "/home/vimos/Data/git/QA/WebAsKB/Models/Pytorch/encoder.py", line 26, in forward
dep_parse_embedded = self.embedding(input[1]).view(1, 1, -1)
File "/home/vimos/anaconda3/envs/webaskb/lib/python3.6/site-packages/torch/nn/modules/module.py", line 357, in __call__
result = self.forward(*input, **kwargs)
File "/home/vimos/anaconda3/envs/webaskb/lib/python3.6/site-packages/torch/nn/modules/sparse.py", line 103, in forward
self.scale_grad_by_freq, self.sparse
File "/home/vimos/anaconda3/envs/webaskb/lib/python3.6/site-packages/torch/nn/_functions/thnn/sparse.py", line 57, in forward
output = torch.index_select(weight, 0, indices)
TypeError: torch.index_select received an invalid combination of arguments - got (torch.FloatTensor, int, torch.cuda.LongTensor), but expected (torch.FloatTensor source, int dim, torch.LongTensor index)
I tried to fix the issue with the following method, hope it is the right way:
diff --git a/Models/webaskb_ptrnet.py b/Models/webaskb_ptrnet.py
index 1281fda..dd2cb4e 100644
--- a/Models/webaskb_ptrnet.py
+++ b/Models/webaskb_ptrnet.py
@@ -20,6 +20,10 @@ class WebAsKB_PtrNet_Model():
self.encoder = EncoderRNN(input_lang.n_words, config.hidden_size)
self.decoder = AttnDecoderRNN(config.output_size, config.hidden_size)
+ if config.use_cuda:
+ self.encoder.cuda()
+ self.decoder.cuda()
+
self.criterion = nn.CrossEntropyLoss()
def init_stats(self):
@@ -115,7 +119,7 @@ class WebAsKB_PtrNet_Model():
def format_model_output(self,pairs_dev, result):
input_tokens = [token['dependentGloss'] for token in pairs_dev['aux_data']['sorted_annotatio
ns']]
- output_sup = pairs_dev['y'].view(-1).data.numpy()
+ output_sup = pairs_dev['y'].view(-1).data.cpu().numpy()
comp_names = ['composition', 'conjunction']
comp = comp_names[int(result[0]) - 1]
@@ -210,6 +214,7 @@ class WebAsKB_PtrNet_Model():
decoder_input = target_variable[di]
else:
decoder_input = Variable(torch.LongTensor([[int(np.argmax(decoder_attention.data[0].
tolist()))]]))
+ decoder_input = decoder_input.cuda() if config.use_cuda else decoder_input
# we are computing logistical regression vs the hidden layer!!
if len(target_variable)>0:
Hi, this is true, sorry. The training runs pretty fast on CPU (5-10 hours on average) so due to limited resources i trained it on CPU, future version will support Cuda, again sorry for that.
The repo seems not compatible with cuda.
I tried to fix the issue with the following method, hope it is the right way: