matteosoo / aimsfellows_DL

In the "project" folder, we implemented a website with text writing board which is used for traditional Chinese recognition supplied by CNN.
http://aimsfellows.site.nthu.edu.tw/p/412-1160-17147.php?Lang=zh-tw
0 stars 1 forks source link

load_data 問題 #1

Closed axionoixa closed 4 years ago

axionoixa commented 4 years ago

hi 助教

我目前對於 npg to numpy bitmap 部分的處理方式是將其轉換為 (51, 300, 300, 3) 的格式,但這種方式無法在 load_data 正確執行, 於x = np.concatenate((x, data), axis=0) 會有錯誤,顯示如下訊息: all the input arrays must have same number of dimensions, but the array at index 0 has 2 dimension(s) and the array at index 1 has 4 dimension(s)

我想請問,是否格式轉換錯誤?

是否應該是要轉換成如上課範例的51 90000 的格式? 但我不理解的是, 3003003 如何轉換成 1 90000

matteosoo commented 4 years ago

沒錯, 就如你所說的問題才會使dimension溢出 因為template輸入格式已經把2D image轉換成1D序列作運算

至於轉換方式, 可以利用課堂學到的reshape概念 舉例而言

import numpy as np

# suppose a 10*10 RGB image
tensor2D = np.random.rand(10, 10, 3)
print(tensor2D.shape)
# >>> (10, 10, 3)

tensor1D = np.reshape(tensor2D, (100, 3))
print(tensor1D.shape)
# >>> (100, 3)

另外, 從發問中也想提醒 由於我們影像都是灰階處理(即黑白) 所以參照quickdraw dataset樣子, 我們會把他先做grey scale處理, 而非 3 channels 的RGB 也就是前處理應該先長這樣

# suppose 10*10 grey scale image
tensor2D = np.random.rand(10, 10, 1)
print(tensor2D.shape)
# >>> (10, 10, 1)

tensor1D = np.reshape(tensor2D, (100,))
print(tensor1D.shape)
# >>> (100,)

以上, 希望有幫助

axionoixa commented 4 years ago

Thank you!