RuntimeError:当我附加hdf5文件时,无法创建链接(名称已经存在)? [英] RuntimeError: Unable to create link (name already exists) when I append hdf5 file?

查看:175
本文介绍了RuntimeError:当我附加hdf5文件时,无法创建链接(名称已经存在)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将hdf5数据集附加到先前的hdf5数据集
发生以下错误

I am trying to append the hdf5 dataset to the previous hdf5 dataset
following error occured

h5o.link(obj.id,self.id,name,lcpl = lcpl,lapl = self._lapl)文件 "h5py/_objects.pyx",在h5py._objects.with_phil.wrapper中的第54行,
在h5py._objects.with_phil.wrapper中的文件"h5py/_objects.pyx",第55行 h5py.h5o.link中的文件"h5py/h5o.pyx",行202,RuntimeError:无法 创建链接(名称已经存在)

h5o.link(obj.id, self.id, name, lcpl=lcpl, lapl=self._lapl) File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "h5py/h5o.pyx", line 202, in h5py.h5o.link RuntimeError: Unable to create link (name already exists)

 sal_maps = np.array([], dtype=np.float32).reshape((0,) + img_size)
        probs = np.array([], dtype=np.float32)
        preds = np.array([], dtype=np.uint8)
        for idx, (img, target) in enumerate(dataloader):

    # TODO problem1 idx problem
            sal_maps_b, probs_b, preds_b = self.generate_image(img, idx)
            sal_maps_b = np.transpose(sal_maps_b, axes=(3,0, 1, 2))

            sal_maps = np.vstack([sal_maps,sal_maps_b])
            probs = np.append(probs, probs_b)
            preds = np.append(preds,preds_b)
            #if idx ==2: break
            if idx % 100 == 0:
                print("idx->{} sal_maps->{}, probs->{} , preds->{}".format(idx,sal_maps.shape,probs.shape,preds.shape))

        # TODO indent change

                print("result->{}".format(sal_maps.size))
                with h5py.File(self.datapath, 'a') as hf:
                    hf.create_dataset('saliencys', data=sal_maps)
                    hf.create_dataset('probs', data=probs)
                    hf.create_dataset('preds', data=preds)
                    hf.close()
                sal_maps = np.array([], dtype=np.float32).reshape((0,) + img_size)
                probs = np.array([], dtype=np.float32)
                preds = np.array([], dtype=np.uint8)
                print('Save_saliency_maps::',idx)

推荐答案

  1. 转到: Miniconda3 \ Lib \ site-packages或任何安装h5py的地方.

  1. Go to: Miniconda3\Lib\site-packages or wherever h5py is installed.

删除h5py文件夹

删除h5py-2.10.0.dist-info文件夹(如果您使用其他版本,则可能会有所不同.)

Delete h5py-2.10.0.dist-info Folder (This might be different if you have a different 4. version).

再次安装h5py.

经过长时间的搜索,它对我有用. 最后,我尝试手动将其删除并重新安装. 它工作了!!!!!!

It worked for me after a long search. Finally, I tried to delete it manually and reinstall it. IT WORKED!!!!!

通过使用cmd,pip和anaconda卸载它们 某些文件可能会卡住,甚至在安装其他版本后也会导致错误.

By uninstalling them using cmd, pip, anaconda Some files might stuck and will cause errors even after installing a different version.

这篇关于RuntimeError:当我附加hdf5文件时,无法创建链接(名称已经存在)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆