tbepler / topaz

Pipeline for particle picking in cryo-electron microscopy images using convolutional neural networks trained from positive and unlabeled examples. Also featuring micrograph and tomogram denoising with DNNs.
GNU General Public License v3.0
172 stars 64 forks source link

Problem with data loader #9

Closed bHimes closed 5 years ago

bHimes commented 5 years ago

I'm working through the "complete walkthrough" and ran into a snag when I got to the training step.

My input

(base) [himesb@london testTopaz]$ topaz train -n 300 \
>             --num-workers=8 \
>             --train-images data/EMPIAR-10025/processed/image_list_train.txt \
>             --train-targets data/EMPIAR-10025/processed/particles_train.txt \
>             --test-images data/EMPIAR-10025/processed/image_list_test.txt \
>             --test-targets data/EMPIAR-10025/processed/particles_test.txt \
>             --save-prefix=saved_models/EMPIAR-10025/model \
>             -o saved_models/EMPIAR-10025/model_training.txt

Output:

# Loading model: resnet8
# Model parameters: units=32, dropout=0.0, bn=on
# Receptive field: 71
# Using device=0 with cuda=True
# Loaded 20 training micrographs with 1000 labeled particles
# Loaded 10 test micrographs with 500 labeled particles
# source        split   p_observed      num_positive_regions    total_regions
# 0     train   0.00654 29000   4435200
# 0     test    0.00654 14500   2217600
# Specified expected number of particle per micrograph = 300.0
# With radius = 3
# Setting pi = 0.03923160173160173
# minibatch_size=256, epoch_size=5000, num_epochs=10

Error Message

Traceback (most recent call last):
  File "/groups/grigorieff/home/himesb/thirdParty/anaconda3/bin/topaz", line 11, in <module>
    load_entry_point('topaz', 'console_scripts', 'topaz')()
  File "/groups/grigorieff/home/himesb/thirdParty/topaz/topaz/main.py", line 144, in main
    args.func(args)
  File "/groups/grigorieff/home/himesb/thirdParty/topaz/topaz/commands/train.py", line 649, in main
    classifier.width, split, args)
  File "/groups/grigorieff/home/himesb/thirdParty/topaz/topaz/commands/train.py", line 471, in make_data_iterators
    , num_workers=num_workers)
  File "/groups/grigorieff/home/himesb/thirdParty/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 805, in __init__
    batch_sampler = BatchSampler(sampler, batch_size, drop_last)
  File "/groups/grigorieff/home/himesb/thirdParty/anaconda3/lib/python3.6/site-packages/torch/utils/data/sampler.py", line 146, in __init__
    .format(sampler))

ValueError: sampler should be an instance of torch.utils.data.Sampler, but got sampler=<topaz.utils.data.sampler.StratifiedCoordinateSampler object at 0x7f6b74093cf8>

(last line pulled from error msg for emphasis)

tbepler commented 5 years ago

What version of pytorch do you have installed? Topaz requires version 0.2.0 of pytorch because newer versions are not backwards compatible. I suspect that is causing this problem.

bHimes commented 5 years ago

I had everything but pillow installed, and so had missed the " = " sign relative to the " >= " in the list of dependencies when I scanned over them. Downgrading the installation took care of the problem. Thanks you!