pytorchviz icon indicating copy to clipboard operation
pytorchviz copied to clipboard

How to adjust the resolution of the saved dot image?

Open Jian-danai opened this issue 6 years ago • 2 comments

How to adjust the resolution of the saved dot image? My computational graph is too long...then the image seems not clear enough. image

Jian-danai avatar Mar 28 '20 07:03 Jian-danai

@Jian-danai very easy

def resize_graph(dot, size_per_element=0.15, min_size=12):
    """Resize the graph according to how much content it contains.
    Modify the graph in place.
    """
    # Get the approximate number of nodes and edges
    num_rows = len(dot.body)
    content_size = num_rows * size_per_element
    size = max(min_size, content_size)
    size_str = str(size) + "," + str(size)
    dot.graph_attr.update(size=size_str)


resize_graph(dot,size_per_element=1,min_size=20)
dot.format = 'png'
dot.render('hehe')

ucalyptus avatar Sep 25 '20 17:09 ucalyptus

Use svg format:

output  = model(inputs)
dot = make_dot(output).render("filename", format="svg")

mkmohangb avatar Jul 14 '22 14:07 mkmohangb