[問題] Python reshape問題

看板Python作者 (gecer)時間4年前 (2020/01/25 18:31), 編輯推噓2(202)
留言4則, 2人參與, 4年前最新討論串1/1
https://www.kaggle.com/halien/simple-image-classifer-with-svm data_images = digits.images.reshape((n_samples, -1)) 請問reshape 裡面 "-1" 是什麼意思? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.174.60.86 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1579948283.A.7B0.html

01/25 18:55, 4年前 , 1F
可以理解成自動判斷的意思
01/25 18:55, 1F

01/25 18:55, 4年前 , 2F
例如原本a.shape=(2, 3, 4)
01/25 18:55, 2F

01/25 18:55, 4年前 , 3F
則a.reshape(3, -1)=(3, 8)
01/25 18:55, 3F

01/26 13:57, 4年前 , 4F
那個項會自動填上整除的維度
01/26 13:57, 4F
文章代碼(AID): #1UB1ZxUm (Python)