Traceback (most recent call last):
File "train_ammeter_twoclass.py", line 189, in <module>
train(epoch)
File "train_ammeter_twoclass.py", line 133, in train
outputs = net(inputs)
File "/home/iot/miniconda2/envs/pytorch3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
result = self.forward(*input, **kwargs)
File "/home/iot/chenjun/1_program/classifer/src/model.py", line 79, in forward
x = self.net(x) # inception will return two matrices
File "/home/iot/miniconda2/envs/pytorch3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
result = self.forward(*input, **kwargs)
File "/home/iot/miniconda2/envs/pytorch3/lib/python3.6/site-packages/torchvision/models/inception.py", line 109, in forward
aux = self.AuxLogits(x)
File "/home/iot/miniconda2/envs/pytorch3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
result = self.forward(*input, **kwargs)
File "/home/iot/miniconda2/envs/pytorch3/lib/python3.6/site-packages/torchvision/models/inception.py", line 308, in forward
x = self.conv1(x)
File "/home/iot/miniconda2/envs/pytorch3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
result = self.forward(*input, **kwargs)
File "/home/iot/miniconda2/envs/pytorch3/lib/python3.6/site-packages/torchvision/models/inception.py", line 326, in forward
x = self.bn(x)
File "/home/iot/miniconda2/envs/pytorch3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
result = self.forward(*input, **kwargs)
File "/home/iot/miniconda2/envs/pytorch3/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 66, in forward
exponential_average_factor, self.eps)
File "/home/iot/miniconda2/envs/pytorch3/lib/python3.6/site-packages/torch/nn/functional.py", line 1251, in batch_norm
raise ValueError('Expected more than 1 value per channel when training, got input size {}'.format(size))
ValueError: Expected more than 1 value per channel when training, got input size [1, 768, 1, 1]
Problem analysis: batch nomolization is used in the model. When batch is used in training, there should be an odd number. For example, the total number of samples of dataset is 17, and your batch number is 0_ If the size is 8, such an error will be reported.
Solution: delete a sample from the dataset.
Converted from: valueerror: expected more than 1 value per channel when training, got input size torch.Size ([1, 768, 1, 1])
Read More:
- [Solved] RuntimeError: cublas runtime error : resource allocation failed at
- [Solved] Torch Build Module Error: NotImplementedError
- [Solved] PyTorch Caught RuntimeError in DataLoader worker process 0和invalid argument 0: Sizes of tensors mus
- Python RuntimeError: Expected 4-dimensional input for 4-dimensional weight [32, 1, 5, 5]
- [Solved] RuntimeError: ProcessGroupNCCL is only supported with GPUs, no GPUs found
- [Solved] bushi RuntimeError: version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at /pytorch/caffe2/s
- pytest pluggy.manager.PluginValidationError: unknown hook’pytest_namespace’ error handling method
- [Solved] mmdetection benchmark.py Error: RuntimeError: Distributed package doesn‘t have NCCL built in
- [Solved] RuntimeError: cuda runtime error (100) : no CUDA-capable device is detected at
- Python PIP TypeError: expected str, bytes or os.PathLike object, not int
- How to Solve Error: RuntimeError CUDA out of memory
- [Solved] Python matplotlib Error: RuntimeError: In set_size: Could not set the fontsize…
- [Solved] socketio.exceptions.ConnectionError: OPEN packet not returned by server
- [Solved] django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.Did you install mysqlclie
- How to Solve Python Importerror: DLL load failed: unable to find the specified program using tensorflow
- [Mac Pro M1] Python3.9 import cv2 Error: Reason: image not found
- RuntimeError: Address already in use [How to Solve]
- visdom Install and Run Error: raise Connectionerror [How to Solve]
- Install PyTorch in Anaconda environment
- AttributeError: can‘t set attribute [How to Solve]