当试图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