Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ArthurDelannoyazerty/2d3897c7e9e71b0199ab3aff0de335ee to your computer and use it in GitHub Desktop.
Save ArthurDelannoyazerty/2d3897c7e9e71b0199ab3aff0de335ee to your computer and use it in GitHub Desktop.
Example of code that break the pytorch computation graph.

Things to do to break the computation graph

By using the output of the following code in the flow of the model.

torch.tensor(existing_tensor)
existing_tensor.item()
existing_tensor.detach()
torch.argmax(existing_tensor)
torch.max(existing_tensor).indices      # .value works
existing_tensor[n] = k
existing_tensor.int()   #.long()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment