How to visualize a neural network

前端 未结 8 1068
天涯浪人
天涯浪人 2021-01-30 02:59

I want to draw a dynamic picture for a neural network to watch the weights changed and the activation of neurons during learning. How could I simulate the process in Python?

8条回答
  •  一生所求
    2021-01-30 03:16

    Here is a library based on matplotlib, named viznet (pip install viznet). To begin, you can read this notebook. Here is an example

    Viznet defines a set of brush rules.

    node1 >> (0, 1.2)  # put a node centered at axis (0, 1.2)
    node2 >> (2, 0)    # put a node centered at axis (2, 0)
    edge >> (node1, node2)  # connect two nodes
    

    Here, node1 and node2 are two node brushes, like node1 = NodeBrush('nn.input', ax=d.ax, size='normal')

    The first parameter defines the theme of node. For a neural network node (theme start with 'nn.'), its style refers from Neural Network Zoo Page。

    For edges, we can define its brush like edge = EdgeBrush('->', ax=d.ax, lw=2) The first parameters is the theme,'-' for straight line, '.' for dashed line, '=' for double line, '>','<' are left arrow and right arrow. The proportion of '-', '.' and '=' in a theme code decides their length in a line. For example, '->' and '->-' represents lines with arrow at end and arrow at center respectively. The following are several examples

    With only nodes and edges are not enough, the rule for connection plays a fundamentally role. Except basic connection rule, you can create pins on nodes. I will stop here and leave it for documents. These flexible features make it capable for drawing also tensor networks and quantum circuits.

    This project just embraced its v0.1 release, I will keep improving it. You can access its Github repo for latest version, and wellcome for pulling requests or posting issues!

提交回复
热议问题