有没有办法在 Google Colab 上使用变量检查器?

Naw*_*wel 3 jupyter-notebook google-colaboratory

这是我第一次在 Google Colab 上工作。是否可以在 Google Collab 中使用变量检查器?如果是这样,怎么办?

谢谢。

Rub*_*Rub 7

更新:截至 2022 年 2 月 22 日,Colab 拥有自己的变量检查器。您可以从左侧面板访问它。

在此输入图像描述


是的。我就是这样做的。

将此代码放入一个代码单元中并运行它。

from google.colab import output
#I don't know why nbextensions don't work with python3.6 
with output.temporary():
  !pip install --upgrade git+https://github.com/Kreijstal/colab_inspector.git 
  !python2.7 -m pip install --upgrade git+https://github.com/blois/colab_inspector.git #yes, really.
  !jupyter nbextension install --py inspector

import inspector

# open a scratch cell (Ctrl+Alt+N)
# run there
# inspector.watch_globals()
Run Code Online (Sandbox Code Playgroud)

打开临时单元格(Ctrl+Alt+N)

在其上,运行

inspector.watch_globals()
Run Code Online (Sandbox Code Playgroud)

当您在左侧编码时,您将看到右侧的变量自动更新。您甚至可以扩展字典和其他内容。

在此输入图像描述

在此输入图像描述

参考:

关键词:Google Colab、变量浏览器检查器可视化