当前位置:网站首页>can‘t convert cuda:0 device type tensor to numpy. Use Tensor. cpu() to copy the tensor to host memory
can‘t convert cuda:0 device type tensor to numpy. Use Tensor. cpu() to copy the tensor to host memory
2022-07-28 22:52:00 【Meteor shower ADI】
Source code :
# Training curve
result1 = [100 - i['train'] for i in statistics]
result2 = [100 - i['valid'] for i in statistics]
plt.figure(figsize = (10, 7))
plt.plot(result1, label = 'Training')
plt.plot(result2, label = 'Validation')
plt.xlabel('Step')
plt.ylabel('Error Rate')
plt.legend()Error message :


The wrong content is unable to draw normally , This error message is the same as the one above .cpu() In the same , But the solution is slightly different , I found many ways on the Internet , But no suitable solution has been found , Most of the Internet is talking about adding .cpu(), But as far as this drawing program is concerned , Unable to find a suitable addition .cpu() The place of . The reason is , Still don't really understand the meaning of the program .
First, print the traversed statistics, Look at what's in it .

Pictured above , You can find statistic Itself is a list , And the elements inside are indeed dictionaries , In the dictionary train,valid The corresponding value yes torch Of tensor, That's why there are mistakes .
Change it as follows :
# Training curve
result1 = [100 - i['train'].cpu() for i in statistics]
result2 = [100 - i['valid'].cpu() for i in statistics]
plt.figure(figsize = (10, 7))
plt.plot(result1, label = 'Training')
plt.plot(result2, label = 'Validation')
plt.xlabel('Step')
plt.ylabel('Error Rate')
plt.legend()stay i['train'] and i['valid'] Add .cpu(), Click run again , You can run the program normally .

边栏推荐
- Draem+sspcab [anomaly detection: block]
- Intelligent control -- fuzzy mathematics and control
- Differernet [anomaly detection: normalizing flow]
- OSV_ q The size of tensor a (704) must match the size of tensor b (320) at non-singleton dime
- 《Robust and Communication-Efficient Federated Learning From Non-i.i.d. Data》论文阅读
- STM32 - systick timer (cubemx configures systick)
- Bluetooth smart Bracelet system based on STM32 MCU
- Gd32f303 firmware library development (10) -- dual ADC polling mode scanning multiple channels
- es学习目录
- 软件测试工具fiddler postman jmeter charlse核心功能总结
猜你喜欢
![[3D target detection] 3dssd (I)](/img/84/bcd3fe0ba811ea79248a5f50b15429.png)
[3D target detection] 3dssd (I)
![MKD [anomaly detection: knowledge disruption]](/img/15/10f5c8d6851e94dac764517c488dbc.png)
MKD [anomaly detection: knowledge disruption]

【三维目标检测】3DSSD(一)

Improvement 17 of yolov5: cnn+transformer -- integrating bottleneck transformers

console.log()控制台显示...解决办法

C language to realize string reverse order arrangement

c语言实现字符串逆序排列

高等数学解题常用公式笔记总结

Install PCL and VTK under the background of ROS installation, and solve VTK and PCL_ ROS conflict problem

Record a question about the order of trigonometric function exchange integrals
随机推荐
Learning experience sharing 3: yolov5 training data set path index
hp proliant dl380从U盘启动按哪个键
二进制的原码、反码、补码
Command line agent: proxychains configuration
STM32 -- program startup process
Symbol符号类型
弹框遮罩层「建议收藏」
One of the experience of solving problems with code error reporting: CUDA does not match pytorch
《Shortening passengers’ travel time A dynamic metro train scheduling approach using deep reinforcem》
Stm32+ four pin OLED screen + Chinese character mold taking
Summary of common formula notes for solving problems in Higher Mathematics
Is 1E3 a floating point number?
Learning experience sharing 5: yolov5 dataset division and Yolo format conversion
简单的es高亮实战
STM32 board level support package for keys
[3D target detection] 3dssd (II)
npm run dev,运行项目后自动打开浏览器
Wheel 7: TCP client
771. The longest consecutive character in a string
Binary source code, inverse code, complement code