what(): Expected object of type Variable but found type CUDALongType for argument #2 ‘index’ (checked_ cast_ variable at … /… /torch/csrc/autograd/ VariableTypeManual.cpp:38 )
Problem Description: using the libtorch function torch:: index_ select(detections_ class_ Left, 0, index), the operation will report an error as above and enter the index_ The definition of select shows: static inline tensor index_ select(const Tensor & self, int64_ t dim, const Tensor & index)
Problem analysis:
through the error prompt, argument # 2 ‘index’ should be of variable type, and I use the tensor (data type is cudalongtype), so I always report an error.
Problem solving:
1. Make clear the difference between variable type and tensor, and quote another article’s interpretation: Zhihu’s article;
2. Turn the tensor into a variable and use the function: Torch:: autograd:: make_ variable(left_ index, false);// tensot—> Variable
Read More:
- SpringBoot IntegratenRedis Annotations and access error: EL1008E: Property or field ‘getListMember‘ cannot be found on object of type
- [Solved] Runtimeerror during dcgan training: found dtype long but expected float
- [How to Fix]Type error: must use keyword argument for key function
- Type error: must use keyword argument for key function
- [Solved] The method getContextPath() from the type HttpServletRequest refers to the missing type String
- [Solved] Kafka Start Log Error: WARN Found a corrupted index file due to requirement failed: Corrupt index found
- TensorFlow issue: Expected int32, got list containing Tensors of type ‘_Message’ instead.
- [Solved] Eureka Startup Error: Root name (‘timestamp‘) does not match expected type EurekaApplications
- [Solved] Error while extracting response for type [] and content type []…
- Error: (list) object cannot be coerced to type ‘double’
- [Solved] MongoDB Error: TypeError: Object of type ObjectId is not JSON serializable
- maven Error: Element ‘dependency’ cannot have character [children], because the type’s content type is
- [Solved] RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and
- [Solved] But was actually of type ‘com. Sun. Proxy. $proxy**‘
- [Solved] Opencv Call yolov3 Error: IndexError: invalid index to scalar variable
- [Solved] TypeError: super(type, obj): obj must be an instance or subtype of type
- [Go] Solve the empty interface interface{} cannot use (type []string) as type []interface {}
- How to Solve Error: Element ‘dependency’ cannot have character [children], because the type’s content type is element-
- How to Solve Error: Type mismatch: cannot convert from Object to Car