YoungXiyuan/DCA

RuntimeError: zero-dimensional tensor (at position 1) cannot be concatenated

Jorigorn opened this issue · 3 comments

May I ask what does cumulative_entity_ids mean?

when I ran it on cpu, it shows:

RuntimeError: zero-dimensional tensor (at position 1) cannot be concatenated

at https://github.com/YoungXiyuan/DCA/blob/master/mulrel_ranker.py
cumulative_entity_ids = torch.cat([cumulative_entity_ids, entity_ids[indx][action.data[0]]], dim=0)

Thanks for your interest in our work, and sorry for my later reply.

The variable "cumulative_entity_ids" denote the list of previously linked entities. (You can refer to the Section 3 in our paper for details)

May I ask you which line in the file "mulrel_ranker.py" caused your reported error, Line #336 or Line #377?

Maybe your reported error is not caused by the variable "cumulative_entity_ids", for that it has been initialized in Line #167 in the file "mulrel_ranker.py" .

@Jorigorn I think this is a pytorch version issues, if you are using torch >= 1.5.0 , this line of code should be written like this

The second position is a zero dimension tensor ( only float ) hence you need to make it an array

line 317, 318

              new_entities = entity_ids[indx][ [ gold.data[indx][0]] ].unsqueeze(0)
              cumulative_entity_ids = torch.cat([ cumulative_entity_ids, new_entities], dim=0)

line 342, 343

                    new_entities = entity_ids[indx][action.data[0]].unsqueeze(0)
                    cumulative_entity_ids = torch.cat([cumulative_entity_ids, new_entities], dim=0)

@theblackcat102 Thank you for your assistance (: