Skip to content
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

tensors used as indices must be long, byte or bool tensors #30

Open
yzj19870824 opened this issue Jun 28, 2021 · 5 comments
Open

tensors used as indices must be long, byte or bool tensors #30

yzj19870824 opened this issue Jun 28, 2021 · 5 comments

Comments

@yzj19870824
Copy link

error occurs when I train model using UMLS dataset

Epoch 2: average training loss = -0.22322563640773296 entropy = 4.2052984714508055
=> saving checkpoint to '/content/MultiHopKG-master/model/umls-point.rs.conve-xavier-n/a-200-200-3-0.001-0.1-0.0-0.95-400-0.05/checkpoint-2.tar'
0% 0/11 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/content/MultiHopKG-master/src/experiments.py", line 765, in
run_experiment(args)
File "/content/MultiHopKG-master/src/experiments.py", line 746, in run_experiment
train(lf)
File "/content/MultiHopKG-master/src/experiments.py", line 235, in train
lf.run_train(train_data, dev_data)
File "/content/MultiHopKG-master/src/learn_framework.py", line 146, in run_train
dev_scores = self.forward(dev_data, verbose=False)
File "/content/MultiHopKG-master/src/learn_framework.py", line 202, in forward
pred_score = self.predict(mini_batch, verbose=verbose)
File "/content/MultiHopKG-master/src/rl/graph_search/pg.py", line 226, in predict
pn, e1, r, e2, kg, self.num_rollout_steps, self.beam_size)
File "/content/MultiHopKG-master/src/rl/graph_search/beam_search.py", line 168, in beam_search
pn.update_path(action, kg, offset=action_offset)
File "/content/MultiHopKG-master/src/rl/graph_search/pn.py", line 187, in update_path
offset_path_history(self.path, offset)
File "/content/MultiHopKG-master/src/rl/graph_search/pn.py", line 176, in offset_path_history
new_tuple = tuple([_x[:, offset, :] for _x in x])
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

Does anyone meet that?

@yzj19870824
Copy link
Author

The type of elements in offset is float indeed.

@seanPudding
Copy link

search for action_beam_offset = action_ind / action_sapce_size and top_unique_beam_offset = top_unique_idx / action_sapce_size
and then modify them to action_beam_offset = action_ind // action_sapce_size and top_unique_beam_offset = top_unique_idx // action_sapce_size
This change can works and I see it in DacKGR, but I am not sure if it's right.

@wenjian-sc
Copy link

搜索action_beam_offset = action_ind / action_sapce_sizetop_unique_beam_offset = top_unique_idx / action_sapce_size然后将它们修改为action_beam_offset = action_ind // action_sapce_sizetop_unique_beam_offset = top_unique_idx // action_sapce_size 此更改可以工作,我在DacKGR中看到它,但我不确定它是否正确。

Which file is this line of code in? Do you mind telling me? I can't find this line of code.
action_beam_offset = action_ind / action_sapce_size和top_unique_beam_offset = top_unique_idx / action_sapce_size

@seanPudding
Copy link

action_beam_offset = action_ind / action_sapce_size (src/rl/graph_search/beam_search.py line:62)
top_unique_beam_offset = top_unique_idx / action_sapce_size (src/rl/graph_search/beam_search.py line:105)

@wenjian-sc
Copy link

action_beam_offset = action_ind / action_sapce_size (src/rl/graph_search/beam_search.py 行:62) top_unique_beam_offset = top_unique_idx / action_sapce_size (src/rl/graph_search/beam_search.py 行:105)

Thank you for your help. I found it. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants