giagrad.display#
- giagrad.display.draw_dot(root, rankdir='LR', **options)[source]#
Returns autograd computational graph as a pygraphviz.Digraph object.
Every node is either an operator or a tensor, when
shape
is Truedata
is not displayed,grad
can be displayed if it is specified. For backward pass visualizationretain_graph
must be enabled, otherwise the computational graph will be deleted, seebackward()
.- Parameters:
rankdir¶ (str, default: 'LR') – Direction to draw the graph, see Graphviz rankdir.
- Keyword Arguments:
Examples
>>> from giagrad.display import draw_dot >>> a = Tensor([[-1.,-2.],[3.,-4.],[-5.,6.]], ... requires_grad=True, name='a') >>> b = a.mean() >>> b.name = 'b' >>> a2 = a.exp() >>> a2.name = "a'" >>> c = Tensor([[2.,2.],[2.,2.],[3.,3.]], ... requires_grad=True, name='c') >>> c = c * a2.log().relu() >>> c.name = "c'" >>> d = b * c >>> d.name = 'd' >>> e = Tensor([[5.,5.,5.]], ... requires_grad=True, name='e') >>> f = e @ d >>> f.name = 'f' >>> g = f.sum() >>> g.name = 'g' >>> draw_dot(g, rankdir='TB')