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] ValueError: Error when checking input: expected conv2d_input to have 4 dimensions
- ValueError: Found array with dim 4. Estimator expected and ValueError: Expected 2D array, got 1D array i
- Python RuntimeError: Expected 4-dimensional input for 4-dimensional weight [32, 1, 5, 5]
- [Solved] Pytorch Error: RuntimeError: Error(s) in loading state_dict for Network: size mismatch
- [Solved] Pytorch Error: RuntimeError: expected scalar type Double but found Float
- Pytorch Error: runtimeerror: expected scalar type double but found float
- Solve pytorch multiprocess valueerror: error initializing torch.distributed using env: //rendezvou… Error
- [Solved] PyTorch Caught RuntimeError in DataLoader worker process 0和invalid argument 0: Sizes of tensors mus
- RuntimeError: stack expects each tensor to be equal size, but got [x] at entry 0 and [x] at entry 1
- [Solved] bushi RuntimeError: version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at /pytorch/caffe2/s
- Mxnet.gluon Load Pre Training
- [Solved] torchsummary Error: RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.F
- [Solved] Training yolov5 Error: attributeerror: can get attribute sppf on Module
- pytorch model.load_state_dict Error [How to Solve]
- [Solved] error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘imshow‘
- Python PIP TypeError: expected str, bytes or os.PathLike object, not int
- Pytorch torch.cuda.FloatTensor Error: RuntimeError: one of the variables needed for gradient computation has…
- Pytorch: error message with chunks of 0 [How to Solve]
- [Solved] Python matplotlib Error: RuntimeError: In set_size: Could not set the fontsize…
- Install PyTorch in Anaconda environment