1
我只是想知道如何解決python3.6中的arributeerror。 錯誤是'list'對象沒有屬性'astype'。 我的相關代碼如同打擊。如何解決AttributeError:'list'對象沒有屬性'astype'?
def _init_mean_std(self, data):
data = data.astype('float32')
self.mean, self.std = np.mean(data), np.std(data)
self.save_meanstd()
return data
有沒有人可以給我建議? 謝謝!
通過將'data'轉換爲具有'astype'屬性的東西。說,一個numpy數組。做'numpy進口np; data = np.array(data).astype('float32')' – Kanak
我不知道你是否自願做,但是請注意,默認'np.array(data)'實際上會產生' float64's。通過執行'print(data.dtype)'來檢查。 – Kanak