Problem Description: BTS code today, all kinds of errors. The amazing thing is that everyone has no problem, only I encounter all kinds of wonderful problems, which are too difficult.
Type error: can’t convert CUDA: 0 device type tensor to numpy. Use tensor. CPU () to copy the tensor to host memory first
The solution to this problem is to copy the GPU data to the CPU first, and then save it. But it doesn’t look like that to me. Some people encountered it before because the torch version was wrong, so I reloaded all kinds of versions and combinations, which were unsuccessful.
Only part of the code will be commented out first, and then take a closer look.
Question 2: typeerror:__ array__() takes 1 positional argument but 2 were given
This problem is even more exotic, the image reading error. It is roughly the following situation:
np.array(img) # OK
np.array(img, dtype=np.float64) # Error
After searching for a long time, I finally found that a big guy proposed that it was a PIL bug, and the version was lowered from 8.3 to 8.2 to solve it
Read More:
- Pytorch TypeError: __array__() takes 1 positional argument but 2 were given
- error[E0061]: this function takes 1 argument but 2 arguments were supplied
- TypeError: translate() takes exactly one argument (2 given)
- Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes
- TypeError: Required argument ‘mat‘ (pos 2) not found
- Array of PHP_ diff,array_ intersect,array_ merge, in_ Is there a limit on the number of arrays in array?
- Python about typeerror: required argument ‘mat’ (POS 2) not found error resolution
- TypeError(‘Keyword argument not understood:‘, ‘***‘) in keras.models load_model
- TypeError: drop() got an unexpected keyword argument ‘columns’
- Module build failed: TypeError [ERR_INVALID_ARG_TYPE]: The “path“ argument must be of type string.
- Python TypeError: ‘newline’ is an invalid keyword argument for this function
- TypeError: putText() missing required argument ‘text‘ (pos 2)
- SystemError: new style getargs format but argument is not a tuple
- How to Fix TypeError: Cannot cast array data from dtype(‘float64‘) to dtype(‘<U32‘)….
- TypeError: descriptor ‘__init__‘ of ‘super‘ object needs an argument
- RuntimeError: ‘lengths’ argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor
- Typeerror: write() argument must be STR, not bytes and the method of writing binary file in Python 3
- Typeerror: write() argument must be STR, not bytes and the method of writing binary file in Python 3
- After introducing sass into Vue project, start to report error typeerror [err]_ INVALID_ ARG_ Type]: the “path” argument must be of type string
- [solved] error: valueerror: expected 2D array, got scalar array instead