[this paper records two solutions for error reporting at the same time]
pytorch error: runtimeerror: Boolean value of tensor with more than one value is ambiguous
When writing Python code, if you want to view a dimension of a tenor, you use. Shape at the beginning
if test_image.shape == 3: ......
Resulting error :
RuntimeError: Boolean value of Tensor with more than one value is ambiguous
This is because tensor can’t use .shape, but should use .size
So I wrote it as .size，
if test_image.size == 3: ......
Resulting error reported.
TypeError: ‘builtin_function_or_method’ object is unsubscriptable
This is because the brackets [ ] are written incorrectly and should be used ():
if test_image.size(1) == 3: ......
Solve the problem
- [Solved] tf.summary Error: tags and values not the same shape
- Examples of torch.NN.Functional.Relu() and torch.NN.Relu()
- [Solved] Tensorflow TypeError: Fetch argument array has invalid type ‘numpy.ndarry’
- [Solved] Tensorflow Error: ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray)
- [Solved] RuntimeError: one_hot is only applicable to index tensor
- attributeError: ‘NoneType’ object has no attribute ‘shape’
- Call to a member function row_array()(function_name) on boolean(type)
- Pytorch Install Error: OSError: [WinError 126] Could not Find the Module, Error loading “xx\lib\site-packages\torch\lib\asmjit.dl
- builtin_function_or_method’ object is not subscriptable [How to Solve]
- Weighted cross entropy loss function: tf.nn.weighted_cross_entropy_with_logits