Skip to content

Commit 760fde7

Browse files
committed
解决异常:
File "/content/MultiHopKG-master/src/rl/graph_search/pn.py", line 176, in new_tuple = tuple([_x[:, offset, :] for _x in x]) IndexError: tensors used as indices must be long, byte or bool tensors
1 parent 1e45789 commit 760fde7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/rl/graph_search/beam_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def top_k_action(log_action_dist, action_space):
5959
log_action_prob = log_action_prob.view(-1)
6060
# *** compute parent offset
6161
# [batch_size, k]
62-
action_beam_offset = action_ind / action_space_size
62+
action_beam_offset = action_ind // action_space_size
6363
# [batch_size, 1]
6464
action_batch_offset = int_var_cuda(torch.arange(batch_size) * last_k).unsqueeze(1)
6565
# [batch_size, k] => [batch_size*k]
@@ -102,7 +102,7 @@ def top_k_answer_unique(log_action_dist, action_space):
102102
k_prime = min(len(unique_e_space_b), k)
103103
top_unique_log_action_dist, top_unique_idx2 = torch.topk(unique_log_action_dist, k_prime)
104104
top_unique_idx = unique_idx[top_unique_idx2]
105-
top_unique_beam_offset = top_unique_idx / action_space_size
105+
top_unique_beam_offset = top_unique_idx // action_space_size
106106
top_r = r_space_b[top_unique_idx]
107107
top_e = e_space_b[top_unique_idx]
108108
next_r_list.append(top_r.unsqueeze(0))

0 commit comments

Comments
 (0)