question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When I tried to use the training example of Patch-based pipelines in the help document, the following error occurred

See original GitHub issue

🐛Bug

To reproduce

import torch
import torchio as tio
from torch.utils.data import DataLoader

patch_size = 96
queue_length = 300
samples_per_volume = 10
sampler = tio.data.UniformSampler(patch_size)
subject = tio.datasets.Colin27()
subjects_dataset = tio.SubjectsDataset(10 * [subject])
patches_queue = tio.Queue(
    subjects_dataset,
    queue_length,
    samples_per_volume,
    sampler,
    num_workers=0,
)
patches_loader = DataLoader(patches_queue, batch_size=16)
num_epochs = 2
model = torch.nn.Identity()
for epoch_index in range(num_epochs):
    for patches_batch in patches_loader:
        inputs = patches_batch['t1'][tio.DATA]  # key 't1' is in subject
        targets = patches_batch['brain'][tio.DATA]  # key 'brain' is in subject
        logits = model(inputs)  # model being an instance of torch.nn.Module

Expected behavior

It should be an iterable object

Actual behavior

TypeError: randint(): argument 'high' (position 1) must be int, not numpy.int32

System info

Output of

TypeError: randint(): argument 'high' (position 1) must be int, not numpy.int32

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
rayryengcommented, Feb 22, 2021

This occurs because you have an older version of Numpy. Please update to the latest version. Also make sure you update PyTorch to at least version 1.6.0

0reactions
fepegarcommented, Feb 22, 2021

This occurs because you have an older version of Numpy. Please update to the latest version. Also make sure you update PyTorch to at least version 1.6.0

Thanks, @rayryeng. @Key-lei, feel free to reopen if that solution does not help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Patch-based pipelines - TorchIO - Read the Docs
Patch-based pipelines #. The number of pixels in 2D images used in deep learning is rarely larger than one million. For example, the...
Read more >
Debugging the training pipeline - Hugging Face Course
The error is then often very easy to solve. To demonstrate this, we will use the following script that (tries to) fine-tune a...
Read more >
Training Pipeline failed for the TPOTAutoMLRegression ML ...
I have a small data set of training data and testing data but the training pipeline keeps failing with the following error message:...
Read more >
Patch‐based generative adversarial neural network models ...
Purpose To evaluate pix2pix and CycleGAN and to assess the effects of multiple combination strategies on accuracy for patch-based synthetic ...
Read more >
Combining Regions and Patches for Object Class Localization
framework, where only image-level object occurrence la- bels are available for the training ... There have been a limited number of attempts to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found