當試圖numpy的矩陣M
寫入二進制文件爲:NumPy的不創建二進制文件
from io import open
X = [random.randint(0, 2 ** self.stages - 1)for _ in range(num)]
Matrix = np.asarray([list(map(int, list(x))) for x in X])
file_output = open('result.bin', 'wb')
M = np.ndarray(Matrix, dtype=np.float64)
file_output.write(M)
file_output.close()
我得到這個錯誤:
Traceback (most recent call last):
File "experiments.py", line 164, in <module>
write_data(X, y)
File "experiments.py", line 39, in write_data
arr = np.ndarray(Matrix, dtype=np.float64)
ValueError: sequence too large; cannot be greater than 32
我能知道如何解決這一問題?謝謝
請先修復您的代碼(例如文件名)。 – patrick
你忘了打開一個字符串。請先解決。 –
哦!謝謝 。但仍然有相同的問題 – Medo