-1
print myArray.shape, myArray.dtype # returns (yyy, xxx) uint8
numpy.save('savedFile.npy',myArray)
와 배열을 저장 한 다음 내가 같은 모양의 배열을 얻을 수있는 방법
myArray = numpy.load('savedFile.npy')
print myArray.shape, myArray.dtype # returns (yyy,) object
다시로드하려고로드하고 이전과 같은 dtype?
감사합니다. 코멘트에
import numpy as np
import cv2, os.path
allImageIDs = []
allImages = []
countImagesMax = 20
countImages = 0
while countImages < countImagesMax:
image = np.uint8(np.random.randint(2, size=(144,192)) *255)
allImages.append(np.reshape(image, (image.shape[0]*image.shape[1])))
allImageIDs.append(countImages)
countImages += 1
myArray = [np.array(allImages), np.array(allImageIDs)]
if not os.path.exists("savedFile.npy"):
np.save('savedFile.npy',myArray)
print myArray[0].shape, myArray[0].dtype # returns (yyy, xxx) uint8
else:
myArray = np.load('savedFile.npy')
print myArray[0].shape, myArray[0].dtype # returns (yyy,) object
은 'numpy.save'가 아니라'numpy.safe'라고 말할까요? ;-) – mgilson
예, 그렇습니다 ... 답변을 제공하는 데 도움이됩니까? :) – cowhi
나는 이것을 재현 할 수 없다. 문제를 설명하는 완전하고 독립적 인 예를 포함시킬 수 있습니까? 우리가 복사하고 실행할 수있는 것. 'uint8' 유형의 2D 배열을 저장하고로드하면로드 된 배열의 모양과 유형이 저장된 배열과 동일합니다. –