试图在Python中打开生成的文件时出错

2024-05-16 11:54:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在研究尖峰神经网络,并从https://github.com/peter-u-diehl/stdp-mnist下载了一个基准测试

我有严重的问题运行这个代码,我已经安装了必要的东西。你知道吗

查看代码运行时生成的错误

100%完成,已过0秒,剩余约0秒。你知道吗

100%完成,已过0秒,剩余约0秒。你知道吗

100%完成,已过0秒,剩余约0秒。你知道吗

保存结果

Traceback (most recent call last):

  File "peterb1.py", line 516, in <module>

    np.save(data_path + 'activity/resultPopVecs' + str(num_examples), result_monitor)

  File "/srv/home/compsci/anaconda2/envs/py2b1/lib/python2.7/site-packages

/numpy/lib/npyio.py", line 490, in save

    fid = open(file, "wb")

IOError: [Errno 2] No such file or directory: './activity/resultPopVecs100.npy'

compsci@cclab1-5:~/Desktop/pt1$ 

代码

print ('save results')

if not test_mode:
    save_theta()
if not test_mode:
    save_connections()
else:
    np.save(data_path + 'activity/resultPopVecs' + str(num_examples), result_monitor)
    np.save(data_path + 'activity/inputNumbers' + str(num_examples), input_numbers)

Tags: path代码inpydatasavenpline
1条回答
网友
1楼 · 发布于 2024-05-16 11:54:27

基于您的错误No such file or director: './activity/resultPopVecs100.npy,您可能以错误的方式生成文件路径。你知道吗

  1. 确认在/activity文件夹中有一个名为resultPopVecs100.npy的文件。你知道吗
  2. 使用ospython库生成文件路径。你知道吗

要获得运行脚本的实际系统文件路径,请使用以下代码段,然后使用该BASE_DIR构造文件路径的其余部分。你知道吗

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

相关问题 更多 >