欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

memoryerror: Unable to allocate array with shape (60000, 28, 28) and data ty

发布时间:2024/10/8 编程问答 49 豆豆
生活随笔 收集整理的这篇文章主要介绍了 memoryerror: Unable to allocate array with shape (60000, 28, 28) and data ty 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

使用tf缩放图片遇到

(train_images, train_labels), (test_images,test_labels) = keras.datasets.fashion_mnist.load_data() train_images = train_images / 255.0

memoryerror: Unable to allocate array with shape (60000, 28, 28) and data ty

因为ubunutu似乎要占用的空间太大,所以系统就提前禁止创建了。实际上是用不了那么多内存的

解决办法
首先检查系统的内存过载处理模式
$ cat /proc/sys/vm/overcommit_memory
不出意外的话结果应该是0
然后切换到 root 用户(否则权限不够)
$ sudo passwd root
然后输入当前用户密码,再给 root 设定一个新密码,再切换到 root:
$su root
你会发现KaTeX parse error: Expected 'EOF', got '#' at position 4: 变成了#̲ 现在我们拥有了 root 权… echo 1 > /proc/sys/vm/overcommit_memory`
然后不出意外的话,就可以成功创建该矩阵啦!

总结

以上是生活随笔为你收集整理的memoryerror: Unable to allocate array with shape (60000, 28, 28) and data ty的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。