Hanjun-Dai / pytorch_structure2vec

pytorch implementation of structure2vec (https://arxiv.org/abs/1603.05629)
MIT License
305 stars 76 forks source link

Issue with main.py #11

Closed cothurn closed 5 years ago

cothurn commented 6 years ago

This is what I get running main.py:

=================testing=====================
/home/gtj/summer2018/pytorch_structure2vec/harvard_cep/build/dll/libmol.so
=================doneTsT=====================
====== begin of s2v configuration ======
| msg_average = 0
======   end of s2v configuration ======
loading data
train: 1900000
valid: 82601
test: 220289
loading model from saved/mean_field.model
loading graph from data/test.txt.bin
num_nodes: 6094162  num_edges: 7357400
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 220289/220289 [00:02<00:00, 92711.73it/s]
  0%|                                                                                                                                                  | 0/4406 [00:00<?, ?batch/s]Traceback (most recent call last):
  File "main.py", line 124, in <module>
    test_loss = loop_dataset(test_data, regressor, list(range(len(test_data))))
  File "main.py", line 56, in loop_dataset
    _, mae, mse = regressor(batch_graph)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "main.py", line 101, in forward
    embed = self.s2v(batch_graph, node_feat, edge_feat)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/gtj/summer2018/pytorch_structure2vec/harvard_cep/../s2v_lib/embedding.py", line 50, in forward
    h = self.mean_field(node_feat, edge_feat, n2n_sp, e2n_sp, subg_sp)
  File "/home/gtj/summer2018/pytorch_structure2vec/harvard_cep/../s2v_lib/embedding.py", line 59, in mean_field
    e2npool_input = gnn_spmm(e2n_sp, input_edge_linear)
  File "/home/gtj/summer2018/pytorch_structure2vec/harvard_cep/../s2v_lib/pytorch_util.py", line 70, in gnn_spmm
    return MySpMM.apply(sp_mat, dense_mat)
  File "/home/gtj/summer2018/pytorch_structure2vec/harvard_cep/../s2v_lib/pytorch_util.py", line 56, in forward
    return torch.mm(sp_mat, dense_mat)
RuntimeError: Expected object of type torch.cuda.sparse.FloatTensor but found type torch.sparse.FloatTensor for argument #4 'mat1'
Exception KeyError: KeyError(<weakref at 0x7ff2a58fa7e0; to 'tqdm' at 0x7ff2a599ba10>,) in <bound method tqdm.__del__ of   0%|                                                                                                                                                  | 0/4406 [00:00<?, ?batch/s]> ignored

The issue here is RuntimeError: Expected object of type torch.cuda.sparse.FloatTensor but found type torch.sparse.FloatTensor Not sure the cause of this, as searching torch.cuda.sparse.FloatTensor on google returns nothign revelant.

Hanjun-Dai commented 6 years ago

which version of pytorch are you using?

cothurn commented 6 years ago

0.4.0

Hanjun-Dai commented 6 years ago

I was using 0.3.1. Can you quickly try with this version?

I'll look into 0.4.0.

cothurn commented 6 years ago

0.3.1 Works.

cothurn commented 6 years ago

I wanted to use the bottleneck functionality of 0.4.0, so I am testing with that version. The above error can be avoided by manually converting the tensors to cuda tensors(which leads to the same type error in other locations). In CPU mode, however, I receive this error:

Traceback (most recent call last):
  File "main.py", line 142, in <module>
    avg_loss = loop_dataset(cooked_data_dict['train'], regressor, train_idxes, optimizer, start_iter=i, n_iters=valid_interval)
  File "main.py", line 64, in loop_dataset
    mae = mae.data.numpy()[0]   
IndexError: too many indices for array
Hanjun-Dai commented 6 years ago

mae is a scalar in 0.4.0. If you want to keep with 0.4.0, try mae = mae.data.item()