BMSG-GAN icon indicating copy to clipboard operation
BMSG-GAN copied to clipboard

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

Open HyZhu39 opened this issue 5 years ago • 2 comments

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

HyZhu39 avatar May 17 '19 14:05 HyZhu39

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.

crypticsymmetry avatar Jun 17 '19 16:06 crypticsymmetry

I have the same problem, no idea why

magp18 avatar Jun 06 '20 20:06 magp18