numpy 中出現shape爲0,處理h5數據時的shape爲0是什麼意思?

numpy 中出現shape爲0,處理h5數據時的shape爲0是什麼意思?

研究3D-CNN-UNET的數據讀取時,遇到了下面的代碼:

data_storage = hdf5_file.create_earray(hdf5_file.root, 'data', tables.Float32Atom(), shape=data_shape,
                                       filters=filters, expectedrows=n_samples * Config.voxel_num)

其中,shape=(0,1,28,28,28)中間有個0,查閱源碼註釋如下:

shape : tuple
    The shape of the new array.  One (and only one) of the shape
    dimensions *must* be 0.  The dimension being 0 means that the
    resulting EArray object can be extended along it.  Multiple
    enlargeable dimensions are not supported right now.

翻譯:

存儲的array的shape,第一個維度必須是0,有且僅有這一個,代表這個維度是可拓展的。

因爲這個create_earray就是創建可拓展矩陣的函數(Enlargeable)。
這裏寫0,代表可變。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章