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

A runtime error occurred while running 'train.py'... #10

Open
HyZhu39 opened this issue May 17, 2019 · 2 comments
Open

A runtime error occurred while running 'train.py'... #10

HyZhu39 opened this issue May 17, 2019 · 2 comments

Comments

@HyZhu39
Copy link

HyZhu39 commented May 17, 2019

I encountered this error when I was training in the following configuration:

python train.py --images_dir='data/bird' --folder_distributed=True --sample_dir='samples/exp_1' --model_dir='models/exp_1'

I changed default options in train.py where
"default='os.environ['SM_MODEL_DIR']," to “samples/exp_1',” "default=os.environ['SM_CHANNEL_TRAINING'],“ to "default='data/bird',",
"default='os.environ['SM_MODEL_DIR']," to “samples/exp_1',”

The dataset is loaded correctly.
but it failed in training with this error :

Traceback (most recent call last):
File "train.py", line 267, in
main(parse_arguments())
File "train.py", line 261, in main
start=args.start
File "/data/user/BMSG-GAN/sourcecode/MSG_GAN/GAN.py", line 417, in train
for (i, batch) in enumerate(data, 1):
File "/data/user/.local/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 582, in next
return self._process_next_batch(batch)
File "/data/user/.local/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 608, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
RuntimeError: Traceback (most recent call last):
File "/data/user/.local/lib/python3.5/site-packages/torch/utils/data/_utils/worker.py", line 99, in worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/data/user/.local/lib/python3.5/site-packages/torch/utils/data/utils/worker.py", line 99, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/data/user/BMSG-GAN/sourcecode/data_processing/DataLoader.py", line 132, in getitem
img = self.transform(img)
File "/data/user/.local/lib/python3.5/site-packages/torchvision/transforms/transforms.py", line 60, in call
img = t(img)
File "/data/user/.local/lib/python3.5/site-packages/torchvision/transforms/transforms.py", line 163, in call
return F.normalize(tensor, self.mean, self.std, self.inplace)
File "/data/user/.local/lib/python3.5/site-packages/torchvision/transforms/functional.py", line 208, in normalize
tensor.sub
(mean[:, None, None]).div
(std[:, None, None])
RuntimeError: output with shape [1, 128, 128] doesn't match the broadcast shape [3, 128, 128]

I think this error has nothing to do with my modification.
Could you please tell me what caused this error?

runtimeerror

@crypticsymmetry
Copy link

Broadcast shape (3, 128, 128) is (rgb, height, width) of image. output shape (1, 128, 128) means it's outputting one color channel, instead of 3/RGB. I think , I don't know that much about coding. Hopefully this helps.

@magp18
Copy link

magp18 commented Jun 6, 2020

I have the same problem, no idea why

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