天天看點

c++與python 資料類型對應

首先,npy是什麼?

npy檔案是numpy專用的二進制檔案。

Numpy binary files (NPY, NPZ)

在深度神經網絡訓練過程中通常需要讀取預訓練權重,預訓練權重通常是 .npy檔案,比如vgg16.npy

讀取:np.load()

一讀進來就是一個numpy.ndarray

儲存:np.save()

c++讀取npy:

https://github.com/jacke121/cnpy/blob/master/cnpy.cpp

npy與c++資料類型對應關系表:

https://docs.scipy.org/doc/numpy-1.10.0/reference/c-api.dtype.html   npy對應的都是大寫    

npy_(u)byte

(unsigned) char

npy_(u)short

(unsigned) short

npy_(u)int

(un