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

RuntimeError: result type Long can't be cast to the desired output type Bool #16

Open
Mary63 opened this issue Jan 12, 2021 · 8 comments

Comments

@Mary63
Copy link

Mary63 commented Jan 12, 2021

Hello there!

I am trying to train this model by running this code: !sh train_CTW1500.sh in google Colab:

but I get this error in my zero epoch:

load the vgg16 weight from ./cache
Start training TextGraph.
Epoch: 0 : LR = [0.001]
Traceback (most recent call last):
File "train_TextGraph.py", line 236, in
main()
File "train_TextGraph.py", line 217, in main
train(model, train_loader, criterion, scheduler, optimizer, epoch, logger)
File "train_TextGraph.py", line 74, in train
output, gcn_data = model(img, gt_roi, to_device)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/content/drive/My Drive/Colab Notebooks/DRRG/network/textnet.py", line 122, in forward
feat_batch, adj_batch, h1id_batch, gtmat_batch = self.graph(graph_feat, roi_data)
File "/content/drive/My Drive/Colab Notebooks/DRRG/layers/gcn_layer.py", line 176, in call
batch_data = self.graph_IPS(feat_bin, labels_bin, hops_bin, one_hops_bin, knn_graph_bin)
File "/content/drive/My Drive/Colab Notebooks/DRRG/layers/gcn_layer.py", line 114, in graph_IPS
& labels_gt[center_idx] > 0).long()
RuntimeError: result type Long can't be cast to the desired output type Bool

Can you help me to resolve this issue please?

@Mary63
Copy link
Author

Mary63 commented Jan 25, 2021

Hi there!

I still stock in this step. Would you please help me? I really need to figure this out.

@superblackwoo
Copy link

I stock in this step too

@superblackwoo
Copy link

I stock in this step too.

@GXYM
Copy link
Owner

GXYM commented Apr 20, 2021

Hello there!

I am trying to train this model by running this code: !sh train_CTW1500.sh in google Colab:

but I get this error in my zero epoch:

load the vgg16 weight from ./cache
Start training TextGraph.
Epoch: 0 : LR = [0.001]
Traceback (most recent call last):
File "train_TextGraph.py", line 236, in
main()
File "train_TextGraph.py", line 217, in main
train(model, train_loader, criterion, scheduler, optimizer, epoch, logger)
File "train_TextGraph.py", line 74, in train
output, gcn_data = model(img, gt_roi, to_device)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/content/drive/My Drive/Colab Notebooks/DRRG/network/textnet.py", line 122, in forward
feat_batch, adj_batch, h1id_batch, gtmat_batch = self.graph(graph_feat, roi_data)
File "/content/drive/My Drive/Colab Notebooks/DRRG/layers/gcn_layer.py", line 176, in call
batch_data = self.graph_IPS(feat_bin, labels_bin, hops_bin, one_hops_bin, knn_graph_bin)
File "/content/drive/My Drive/Colab Notebooks/DRRG/layers/gcn_layer.py", line 114, in graph_IPS
& labels_gt[center_idx] > 0).long()
RuntimeError: result type Long can't be cast to the desired output type Bool

Can you help me to resolve this issue please?

This may be caused by Python and python versions. You can modify the data type of the corresponding tensor according to the error message.

@Outerskyb
Copy link

Outerskyb commented Jul 7, 2021

I'm not sure It works (I can not run the code. because of GPU problems)

change line 114 to & (labels_gt[center_idx] > 0)).long() #adding parenthesis

@yjdqk
Copy link

yjdqk commented Aug 4, 2021

I meet this error too ,and I have solved it ! you should confirm that your environment is as same as the required version,install the right versions pkg ,then the error is solved.

@gjm441
Copy link

gjm441 commented Oct 20, 2021

I modify the code as follows, then it can run:
labels = torch.from_numpy(labels_gt[ips]).type(torch.long)
one_hop_labels = labels[one_hop_idcs]
label_tmp =torch.from_numpy(np.array(labels_gt[center_idx]))
edge_labels = (labels_gt[center_idx] == one_hop_labels) & (label_tmp > 0)
edge_labels = edge_labels.long()

@hlzzzzzzz
Copy link

我按如下方式修改代码,然后它可以运行:labels = torch.from_numpy(labels_gt[ips]).type(torch.long) one_hop_labels = labels[one_hop_idcs] label_tmp =torch.from_numpy(np.array(labels_gt[center_idx])) edge_labels = (labels_gt[center_idx] == one_hop_labels) & (label_tmp > 0) edge_labels = edge_labels.long()

where is this code?

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

7 participants