RuntimeError: expected scalar type Long but found Bool

username: monee_h.a
cooked: <p>Hi,</p>
<p>I am getting the following error:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/3/23af5aa0dfb9c824a642d816e683d42d6fe6d142.png" data-download-href="https://discuss.pytorch.org/uploads/default/23af5aa0dfb9c824a642d816e683d42d6fe6d142" title="Screen Shot 2021-05-31 at 12.58.21 AM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/2/3/23af5aa0dfb9c824a642d816e683d42d6fe6d142_2_690x455.png" alt="Screen Shot 2021-05-31 at 12.58.21 AM" data-base62-sha1="55Gp9zeLko8o4xmkAYXBpo5xSyC" width="690" height="455" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/2/3/23af5aa0dfb9c824a642d816e683d42d6fe6d142_2_690x455.png, https://discuss.pytorch.org/uploads/default/optimized/3X/2/3/23af5aa0dfb9c824a642d816e683d42d6fe6d142_2_1035x682.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/2/3/23af5aa0dfb9c824a642d816e683d42d6fe6d142_2_1380x910.png 2x" data-dominant-color="F6F6F6"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screen Shot 2021-05-31 at 12.58.21 AM</span><span class="informations">2022×1336 380 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>While I am running the following code:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/6/d/6daf40ad2f291d22cc0cb396d8c699bfa498844e.png" data-download-href="https://discuss.pytorch.org/uploads/default/6daf40ad2f291d22cc0cb396d8c699bfa498844e" title="Screen Shot 2021-05-31 at 1.03.24 AM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/6/d/6daf40ad2f291d22cc0cb396d8c699bfa498844e_2_690x226.png" alt="Screen Shot 2021-05-31 at 1.03.24 AM" data-base62-sha1="fEjwk0uicnKc5cQwzfF1Iqc8kCa" width="690" height="226" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/6/d/6daf40ad2f291d22cc0cb396d8c699bfa498844e_2_690x226.png, https://discuss.pytorch.org/uploads/default/optimized/3X/6/d/6daf40ad2f291d22cc0cb396d8c699bfa498844e_2_1035x339.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/6/d/6daf40ad2f291d22cc0cb396d8c699bfa498844e_2_1380x452.png 2x" data-dominant-color="D3D2E4"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screen Shot 2021-05-31 at 1.03.24 AM</span><span class="informations">2010×660 146 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>This is what in train method:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/3/03c408fe33fe25ed0f289082e16f7f1e217bc388.png" data-download-href="https://discuss.pytorch.org/uploads/default/03c408fe33fe25ed0f289082e16f7f1e217bc388" title="Screen Shot 2021-05-31 at 1.05.10 AM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/0/3/03c408fe33fe25ed0f289082e16f7f1e217bc388_2_690x347.png" alt="Screen Shot 2021-05-31 at 1.05.10 AM" data-base62-sha1="xjr0YwDP7rgoqM9vNEoCT2NPv2" width="690" height="347" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/0/3/03c408fe33fe25ed0f289082e16f7f1e217bc388_2_690x347.png, https://discuss.pytorch.org/uploads/default/optimized/3X/0/3/03c408fe33fe25ed0f289082e16f7f1e217bc388_2_1035x520.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/0/3/03c408fe33fe25ed0f289082e16f7f1e217bc388_2_1380x694.png 2x" data-dominant-color="ECECEC"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screen Shot 2021-05-31 at 1.05.10 AM</span><span class="informations">1606×808 126 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>I am stuck with this error and I would appreciate your help. Please note when I change the data type from bool to long for masks I am getting 0s only in pred, 0s only in y_pred, and 0s only in y_true, and this is not should be the case. Please advice.</p>
<p>Thank you.</p>

username: monee_h.a
cooked: <p><a class="mention" href="/u/ptrblck">@ptrblck</a> could you please help me ?</p>

username: ptrblck
cooked: <p>Based on the error message <code>torch_cluster/sampler.py</code> is raising this error, as <code>LongTensor</code>s are expected.</p>
<aside class="quote no-group" data-username="monee_h.a" data-post="1" data-topic="122823">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/monee_h.a/48/34621_2.png" class="avatar"> monee_h.a:</div>
<blockquote>
<p>Please note when I change the data type from bool to long for masks I am getting 0s only in pred, 0s only in y_pred, and 0s only in y_true, and this is not should be the case. Please advice.</p>
</blockquote>
</aside>
<p>Converting a <code>BoolTensor</code> to a <code>LongTensor</code> will only return all zeros, if the <code>BoolTensor</code> was containing only <code>False</code> values, so it might be expected.</p>

username: monee_h.a
cooked: <p>This helps. Thank you!</p>