您好,我无法打包和解包联机的二进制文件。错误消息是:
“在_load_data魔术中,num = struct.unpack(“ II”,flbl.read(8))struct.error:解压缩需要8个字节的缓冲区”
def _load_data(pth_images, pth_labels):
with open(pth_labels, 'rb') as flbl:
magic, num = struct.unpack("II", flbl.read(8))
lbl = np.fromfile(flbl, dtype=np.int8)
with open(pth_images, 'rb') as fimg:
magic, num, rows, cols = struct.unpack("IIII", fimg.read(16))
img = np.fromfile(fimg, dtype=np.uint8).reshape(len(lbl), rows, cols)
return np.transpose(img, (0, 2, 1)), lbl - 1
这很奇怪,因为我在struct.unpack()中使用了“ II”-两个无符号整数,它们分别是:4 + 4 = 8位,(以前是“ II”和“ IIII”格式)为什么解释器告诉我一个错误?谢谢。