Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add torchviz library to draw computational graph #2499

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zzowenzz
Copy link

@zzowenzz zzowenzz commented May 24, 2023

Description of changes:

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.

Add several paragraph to discuss the computational graph in pytorch and show an example of using torchviz to automatically generate a computational graph. Here is an example and a screenshot of the generated graph:

from torchviz import make_dot

# Create some tensors and perform operations
x = torch.tensor([2.0], requires_grad=True)
y = torch.tensor([3.0], requires_grad=True)
z = x + y
output = z * z

# Visualise the computational graph
dot = make_dot(output, params={"x": x, "y": y})

# Save the graph as a PDF file
dot.render("computational_graph", format="png")

generated graph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant