1.ndarray->tensor :

b=torch.from_numpy(a)

2.tensor->ndarray:

b=a.numpy()

'''
但这么写会报错……
RuntimeError: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead.
'''
# 修改为
b=a.detach().numpy() '''
gpu上的tensor不能直接转为numpy
'''
b=a.cpu().numpy()

3.ndarray->list

b=a.tolist()

4.list->ndarray

b=numpy.array(a)

最新文章

  1. 基于Bootstrap里面的Button dropdown打造自定义select
  2. ProgressBar
  3. 用eclipse做项目中常遇到的问题-如何创建并读取properties文件
  4. Swift内存管理、weak和unowned以及两者区别
  5. 自定义Dialog之信息提示
  6. 各种 starter poms (启动器)
  7. 为SpringMvc项目安装BootStrap和AngularJs前端框架
  8. javascript自执行匿名函数
  9. Objective-C中字典的使用方法总结
  10. [react native] Error loading page
  11. HDU 1162 Eddy's picture
  12. tcpdump 抓包让wireshark来分析
  13. [转]new一个Object对象占用多少内存?
  14. HTML一些小细节
  15. Delphi临界区的使用
  16. python:发送消息给微信企业号
  17. 「洛谷4197」「BZOJ3545」peak【线段树合并】
  18. Html5与Css3知识点拾遗(一)
  19. 【代码笔记】iOS-获得现在的时间(2015-09-11)
  20. 格式化输出函数:printf 那些事 (C语言)

热门文章

  1. Computer Networking: A Top Down Approach
  2. ASP.NET Core中返回 json 数据首字母大小写问题
  3. FreePascal - CodeTyphon 如何调整代码编辑器背景色?
  4. mysql-luster没有data目录
  5. php集成开发环境搭建三种方式
  6. unittest管理用例生成测试报告
  7. OSPF 高级配置
  8. 记录SQLAlchemy的基本使用
  9. maven nexus 私服搭建 Windows版
  10. php72w-common conflicts with php-common-5.4.16-46.el7.x86_64