MXBoard — 助力 MXNet 数据可视化


#1

Blog 链接:https://zh.mxnet.io/blog/mxboard
微信公众号链接:https://mp.weixin.qq.com/s/jusFEqaFJ2dzTh6U-8j0SQ


#2

mxnet真是越来越棒了


#3

撒花庆贺!


#4

正式版会支持scala吗?


#5

真-重复造轮子?:joy:


#6

给俊哥点赞


#7

最近可视化了一下alexnet,发现计算图里没有数据的shape

代码如下

net = models.AlexNet(classes=10)
net.hybridize()
net.initialize()
net.forward(nd.ones((1, 3, 227, 227)))

sw = SummaryWriter('./log')
sw.add_graph(net)

另外,好像不能add初始化在gpu上的图


#8

安装过程中出现问题。


已经安装了protobuf3,但是显示无法编译。


#9

加shape可视化还需要做不少工作,下个release会搞进去。能提供一个GPU上不能显示的图的代码吗?


#10

pip install protobuf3不是Google发布的protobuf。
你需要装的是这个:https://pypi.org/project/protobuf/
pip install protobuf


#11

代码如下

ctx = try_gpu(0)
net = models.AlexNet(classes=10)
net.hybridize()
net.initialize(ctx=ctx, init=init.Xavier())
net.forward(nd.ones((1, 3, 227, 227)))

sw = SummaryWriter('./log/%s' % (time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime())))
sw.add_graph(net)

运行的时候会包下面的错误

/home/tx/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
/home/tx/anaconda3/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py:46: DeprecationWarning: OpenSSL.rand is deprecated - you should use os.urandom instead
  import OpenSSL.SSL
Traceback (most recent call last):
  File "train.py", line 42, in <module>
    net.forward(nd.ones((1, 3, 227, 227)))
  File "/home/tx/anaconda3/lib/python3.6/site-packages/mxnet/gluon/block.py", line 619, in forward
    return self._call_cached_op(x, *args)
  File "/home/tx/anaconda3/lib/python3.6/site-packages/mxnet/gluon/block.py", line 528, in _call_cached_op
    out = self._cached_op(*args)
  File "/home/tx/anaconda3/lib/python3.6/site-packages/mxnet/_ctypes/ndarray.py", line 164, in __call__
    ctypes.byref(out_stypes)))
  File "/home/tx/anaconda3/lib/python3.6/site-packages/mxnet/base.py", line 149, in check_call
    raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [09:35:50] src/imperative/cached_op.cc:392: Check failed: params_.find(default_ctx) != params_.end() CachedOp is not initialized on context cpu(0)

Stack trace returned 10 entries:
[bt] (0) /home/tx/anaconda3/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x320c32) [0x7f974b61cc32]
[bt] (1) /home/tx/anaconda3/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x321208) [0x7f974b61d208]
[bt] (2) /home/tx/anaconda3/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x291a75d) [0x7f974dc1675d]
[bt] (3) /home/tx/anaconda3/lib/python3.6/site-packages/mxnet/libmxnet.so(MXInvokeCachedOp+0x585) [0x7f974db5fef5]
[bt] (4) /home/tx/anaconda3/lib/python3.6/site-packages/mxnet/libmxnet.so(MXInvokeCachedOpEx+0x4f) [0x7f974db603af]
[bt] (5) /home/tx/anaconda3/lib/python3.6/lib-dynload/../../libffi.so.6(ffi_call_unix64+0x4c) [0x7f978c335ec0]
[bt] (6) /home/tx/anaconda3/lib/python3.6/lib-dynload/../../libffi.so.6(ffi_call+0x22d) [0x7f978c33587d]
[bt] (7) /home/tx/anaconda3/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(_ctypes_callproc+0x2ce) [0x7f978c54a82e]
[bt] (8) /home/tx/anaconda3/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(+0x12265) [0x7f978c54b265]
[bt] (9) python(_PyObject_FastCallDict+0x8b) [0x55a7e6bbd54b]



Segmentation fault: 11

然后就会卡住不动


#12


依旧出现问题


#13

这个跟mxboard没有关系,挂在了net.forward。你的网络weights初始化在了gpu上,input也需要是一个在gpu上的ndarray。


#14

pip install protobuf估计只是安装了runtime lib,build mxboard from source你还需要装protobuf compiler。
可以参考这里的教程安装protochttp://google.github.io/proto-lens/installing-protoc.html。
想省事的话直接pip install mxboard应该就可以用了。


#15

的确是这样,已解决,谢谢


#16

搞定了,安装了Protocol Compiler 就可以了,非常感谢


#17

导入mxboard有警告:
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\win32\lib\pywintypes.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module’s documentation for alternative uses
import imp, sys, os

复现代码:
from mxboard import *


#18

Python版本是多少,如果不是3.6升级到3.6看看还有没有。


#19

是的,是py3.6, 64位anaconda 5.1环境


#20

可能还跟python库对应的操作系统有关,我在mac和ubuntu上import没有warning。不过这个warning不是问题,不会影响mxboard的使用。