• Pytorch实现深度学习常见问题


    • RuntimeError: stack expects each tensor to be equal size, but got [3, 300, 300] at entry 0 and [3, 301, 301] at entry 24

    这里的问题出现的原因肯定是在数据预处理处,如下图,当数据使用不同的transforms处理方式时,会导致数据的尺寸大小不统一,从而造成报错

    在这里插入图片描述

    • Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

    在这里插入图片描述

    • pytorch进行代码debug调式的时候无法进行单步调式

    pycharm中 pytorch代码无法单步调试

    最初 num_workers=2

    debug的时候,点击step over,就只显示Connected.无法单步调试。

    原因是,代码中存在多线程。

    1. 解决办法1: 改为num_workers=0
    2. 解决办法2:打开Setting界面, 搜gevent,在如下设置项中勾选“Gevent compatibe“
      在这里插入图片描述

    在PyCharm中,"Gevent compatible"模式是一种调试模式,用于在使用Gevent库时进行调试。Gevent是一个基于协程的Python网络库,它提供了高性能的并发和异步编程能力。

    在"Gevent compatible"模式下,PyCharm会自动处理Gevent库中的协程调度,以便在调试过程中正确地暂停和恢复协程的执行。这样,你就可以在调试过程中逐行查看代码、检查变量值等,而不会影响协程的正常执行

    • conda创建虚拟环境报错
      【bug】【conda】conda.core.subdir_data.Response304ContentUnchanged
    Traceback (most recent call last):
          File "/home/rainbow/miniconda3/lib/python3.7/site-packages/conda/core/subdir_data.py", line 379, in _load
            repodata_fn=self.repodata_fn)
          File "/home/rainbow/miniconda3/lib/python3.7/site-packages/conda/core/subdir_data.py", line 815, in fetch_repodata_remote_request
            raise Response304ContentUnchanged()
        conda.core.subdir_data.Response304ContentUnchanged
    
        During handling of the above exception, another exception occurred:
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    使用 conda clean -i 清空cache后再重新执行命令,success

  • 相关阅读:
    跑步锻炼(蓝桥杯)
    1006 Sign In and Sign Out
    Hadoop生态之Yarn
    推荐算法的三大研究热点
    IO多路复用(select模型实现监控两个设备:自定义设备和鼠标设备)
    Jmeter和Postman那个工具更适合做接口测试?
    Kubernetes 基础架构最佳实践:从架构设计到平台自动化
    LeetCode 005:最长回文子串
    SLAM中提到的相机位姿到底指什么?
    HCIP第十六天——VLAN,STP和STP角色选举
  • 原文地址:https://blog.csdn.net/Mr_Robot123/article/details/134021356