当前位置:网站首页>错误:with open(txt_path,‘r‘) as f: FileNotFoundError: [Errno 2] No such file or directory:
错误:with open(txt_path,‘r‘) as f: FileNotFoundError: [Errno 2] No such file or directory:
2022-08-02 03:21:00 【woshicaiji12138】
今天在做深度学习时,出现了如下错误:
root='G:/anaconda/pythonProject2/DATA/HWDB1'
transform = transforms.Compose([transforms.Resize((64,64)),
transforms.ToTensor(),
transforms.Grayscale()
])
# 读取训练集
train_dataset =Mydataset(root+'/train.txt',num_class=10,transforms=transform)
with open(txt_path,‘r’) as f: FileNotFoundError: [Errno 2] No such file or directory: ‘G:\anaconda\pythonProject2\HWDB1/train.txt’
究其原因,在于train.txt文件格式内容都如下所示:./DATA/HWDB1/train\00000\100234.png。
而HWDB1数据集文件名为HWDB1,因而绝对路径变成了G:/anaconda/pythonProject2/HWDB1/HWDB1,自然无法找到该路径。
所以只需要将文件夹HWDB1改名为DATA,使路径名为G:\anaconda\pythonProject2\DATA\HWDB1即可。
边栏推荐
猜你喜欢
随机推荐
Day34 LeetCode
Using WebShell to get Shell Skills
线性代数学习笔记2-2:向量空间、子空间、最大无关组、基、秩与空间维数
Scaffolding installation
线性代数学习笔记3-2:矩阵乘法的理解
关于跨域问题
ModuleNotFoundError No module named ‘xxx‘可能的解决方案大全
Chapter 10 聚类
支付通道对接常见的问题有哪些?
MySQL分组后排序
黑马案例--实现 clock 时钟的web服务器
@Autowired详解[email protected]在static属性上的使用
磷脂-聚乙二醇-叠氮,DSPE-PEG-Azide,DSPE-PEG-N3,MW:5000
oracle内连接和外连接
@Autowired注解的使用
LeetCode:第304场周赛【总结】
MongoDB文档存储
mysql创建表
浏览器的工作原理(dns域名服务器,tcp握手,ssl/tls安全协议,关键渲染路径,重绘及回流,防抖和节流)
Redis安装,基本命令,持久化方式,集群








![[详解C语言]一文带你玩转C语言小游戏---扫雷](/img/9f/3979ef063f10bd641111aa4f4d8b4e.png)
