1
在这里蟒蛇h5py错误是我的问题,它工作在1的情况下,而不是在案件2:喂多维数据集
import h5py
import numpy as np
data = np.random.randint(0,256,(5,), np.uint8)
f = h5py.File('test.h5','w')
f.create_dataset('1',(3,5), np.uint8)
f.create_dataset('2',(1,3,5), np.uint8)
print("case 1 before:\n",f['1'].value)
# case 1 before:
# [[0 0 0 0 0]
# [0 0 0 0 0]
# [0 0 0 0 0]]
f['1'][0] = data
print("case 1 after:\n",f['1'].value)
# case 1 after:
# [[ 75 215 125 175 193]
# [ 0 0 0 0 0]
# [ 0 0 0 0 0]]
print()
print()
print("case 2 before:\n",f['2'].value)
# case 2 before:
# [[[0 0 0 0 0]
# [0 0 0 0 0]
# [0 0 0 0 0]]]
f['2'][0][0] = data
print("case 2 after:\n",f['2'].value)
# case 2 after:
# [[[0 0 0 0 0]
# [0 0 0 0 0]
# [0 0 0 0 0]]]
没有人能向我解释什么,我做错了什么? (请不要建议创建一个与我的数据集形状相等的np.array形状,因为我的工作方式更多维数/大小!!)
'不起作用'是报告问题的不好方法。为了帮助我必须重复您的计算,并亲自查看它产生的错误或错误结果。我不应该那样做。 – hpaulj