简体   繁体   English

Jupyter Notebook 中 Google Colaboratory 上的 IOPub 错误

[英]IOPub Error on Google Colaboratory in Jupyter Notebook

I understand that the below command我明白下面的命令

jupyter notebook --NotebookApp.iopub_data_rate_limit=1.0e10 

would let me set the data rate.让我设置数据速率。 But on Colab, I cannot run this command since the notebook is already open.但是在 Colab 上,我无法运行此命令,因为笔记本已打开。

Is there any way I can avoid getting the IOPub error in an active notebook on Colab?有什么方法可以避免在 Colab 上的活动笔记本中出现 IOPub 错误?

I am running keras code and I get this error when I train my neural network.我正在运行 keras 代码,但在训练神经网络时出现此错误。 I really need to see the output since it lets me know how many epochs have been completed and the accuracy.我真的需要查看输出,因为它让我知道已经完成了多少个时代和准确性。

IoPub Error is occurring in Colab because you are trying to display the output on the console itself(Eg. print() statements) which is very large. Colab 中发生 IoPub 错误,因为您试图在控制台本身上显示非常大的输出(例如 print() 语句)。

So the work around would be, Write the output to the file(instead of print statements) and download the file from the Colab所以解决方法是,将输出写入文件(而不是打印语句)并从 Colab 下载文件

Note: Please do avoid writing simple print statements(just to print your contents in datasets) when you are training with large dataset注意:当您使用大型数据集进行训练时,请避免编写简单的打印语句(只是为了打印数据集中的内容)

You can use pprint module from python library.您可以使用 python 库中的pprint 模块 It works well from colab.它在 colab 中运行良好。 However, colab prints output in limited number of line such as 5,000 lines on screen if it exceeds output limit.但是,如果超出输出限制,colab 会以有限的行数(例如 5,000 行)在屏幕上打印输出。

from pprint import pprint

printable = 'long statement'
pprint(printable)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM