Skip to main content

Plotting pytorch tensors made easy

Project description

Logo


torchplot - Plotting pytorch tensors made easy!

Ask yourself the following:

  • Are you using matplotlib.pyplot to plot pytorch tensors?
  • Do you forget to call .cpu().detach().numpy() everytime you want to plot a tensor?

Then torchplot may be something for you. torchplot is a simple drop-in replacement for plotting pytorch tensors. We simply override every matplotlib.pyplot function such that pytorch tensors are automatically converted.

Simply just change your default matplotlib import statement:

Instead of

from matplotlib.pyplot import *

use

from torchplot import *

and instead of

import matplotlib.pyplot as plt

use

import torchplot as plt

Herafter, then you can remove every .cpu().detach().numpy() (or variations heroff) from your code and everything should just work. If you do not want to mix implementations, we recommend importing torchplot as seperaly package:

import torchplot as tp

Installation

Simple as

pip install torchplot

Example

# lets make a scatter plot of two pytorch variables that are stored on gpu
import torch
import torchplot as plt
x = torch.randn(100, requires_grad=True, device='cuda')
y = torch.randn(100, requires_grad=True, device='cuda')
plt.plot(x, y, '.') # easy and simple

Requirements

Tested using torch>=1.6 and matplotlib>=3.3.3 but should perfectly work with both earlier and later versions.

Licence

Please observe the Apache 2.0 license that is listed in this repository.

BibTeX

If you want to cite the framework feel free to use this (but only if you loved it 😊):

@article{detlefsen2021torchplot,
  title={TorchPlot},
  author={Detlefsen, Nicki S.},
  journal={GitHub. Note: https://github.com/CenterBioML/torchplot},
  year={2021}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchplot-0.1.7.tar.gz (9.0 kB view details)

Uploaded Source

File details

Details for the file torchplot-0.1.7.tar.gz.

File metadata

  • Download URL: torchplot-0.1.7.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2.post20210112 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for torchplot-0.1.7.tar.gz
Algorithm Hash digest
SHA256 b591e83bc17e6c758dbe724e3654d25f2a4a1e9b5f3c6080067c4aad227f07f4
MD5 6f0d5e9a43e3c8dc4b2814ab030418fe
BLAKE2b-256 3d2c5400a50b40cba579810c666b4bc2427424dbb097f3810c75da4cbd9f7a42

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page