The goal of this library is to generate more helpful exception messages for matrix algebra expressions for numpy, pytorch, jax, tensorflow, keras, fastai.

Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|

Transformers | 112,231 | 64 | 1,869 | 10 hours ago | 114 | July 18, 2023 | 816 | apache-2.0 | Python | |

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX. | ||||||||||

Real Time Voice Cloning | 42,864 | 2 months ago | 148 | other | Python | |||||

Clone a voice in 5 seconds to generate arbitrary speech in real-time | ||||||||||

Ray | 27,713 | 80 | 298 | 14 hours ago | 87 | July 24, 2023 | 3,410 | apache-2.0 | Python | |

Ray is a unified framework for scaling AI and Python applications. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads. | ||||||||||

Netron | 24,033 | 4 | 69 | a day ago | 587 | August 01, 2023 | 23 | mit | JavaScript | |

Visualizer for neural network, deep learning, and machine learning models | ||||||||||

D2l En | 18,967 | 21 days ago | 2 | November 13, 2022 | 95 | other | Python | |||

Interactive deep learning book with multi-framework code, math, and discussions. Adopted at 500 universities from 70 countries including Stanford, MIT, Harvard, and Cambridge. | ||||||||||

Ncnn | 17,950 | 1 | 12 hours ago | 24 | November 28, 2022 | 1,041 | other | C++ | ||

ncnn is a high-performance neural network inference framework optimized for the mobile platform | ||||||||||

Datasets | 17,157 | 9 | 540 | a day ago | 69 | July 31, 2023 | 601 | apache-2.0 | Python | |

🤗 The largest hub of ready-to-use datasets for ML models with fast, easy-to-use and efficient data manipulation tools | ||||||||||

Deeplearning Models | 15,594 | 7 months ago | 5 | mit | Jupyter Notebook | |||||

A collection of various deep learning architectures, models, and tips | ||||||||||

Onnx | 15,554 | 148 | 394 | 10 hours ago | 29 | May 04, 2023 | 320 | apache-2.0 | Python | |

Open standard for machine learning interoperability | ||||||||||

Best Of Ml Python | 14,459 | a day ago | 18 | cc-by-sa-4.0 | ||||||

🏆 A ranked list of awesome machine learning Python libraries. Updated weekly. |

Alternatives To Tensor SensorSelect To Compare

Alternative Project Comparisons

Readme

See article Clarifying exceptions and visualizing tensor operations in deep learning code and TensorSensor implementation slides (PDF).

(*As of September 2021, M1 macs experience illegal instructions in many of the tensor libraries installed via Anaconda, so you should expect TensorSensor to work only on Intel-based Macs at the moment. PyTorch appears to work.*)

One of the biggest challenges when writing code to implement deep learning networks, particularly for us newbies, is getting all of the tensor (matrix and vector) dimensions to line up properly. It's really easy to lose track of tensor dimensionality in complicated expressions involving multiple tensors and tensor operations. Even when just feeding data into predefined Tensorflow network layers, we still need to get the dimensions right. When you ask for improper computations, you're going to run into some less than helpful exception messages.

To help myself and other programmers debug tensor code, I built this library. TensorSensor clarifies exceptions by augmenting messages and visualizing Python code to indicate the shape of tensor variables (see figure to the right for a teaser). It works with Tensorflow, PyTorch, JAX, and Numpy, as well as higher-level libraries like Keras and fastai.

*TensorSensor is currently at 1.0 (December 2021)*.

For more, see examples.ipynb at colab. (The github rendering does not show images for some reason: examples.ipynb.)

```
import numpy as np
n = 200 # number of instances
d = 764 # number of instance features
n_neurons = 100 # how many neurons in this layer?
W = np.random.rand(d,n_neurons)
b = np.random.rand(n_neurons,1)
X = np.random.rand(n,d)
with tsensor.clarify() as c:
Y = W @ X.T + b
```

Displays this in a jupyter notebook or separate window:

Instead of the following default exception message:

```
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 764 is different from 100)
```

TensorSensor augments the message with more information about which operator caused the problem and includes the shape of the operands:

```
Cause: @ on tensor operand W w/shape (764, 100) and operand X.T w/shape (764, 200)
```

You can also get the full computation graph for an expression that includes all of the sub-expression shapes.

```
W = torch.rand(size=(2000,2000), dtype=torch.float64)
b = torch.rand(size=(2000,1), dtype=torch.float64)
h = torch.zeros(size=(1_000_000,), dtype=int)
x = torch.rand(size=(2000,1))
z = torch.rand(size=(2000,1), dtype=torch.complex64)
tsensor.astviz("b = W@b + (h+3).dot(h) + z", sys._getframe())
```

yields the following abstract syntax tree with shapes:

```
pip install tensor-sensor # This will only install the library for you
pip install tensor-sensor[torch] # install pytorch related dependency
pip install tensor-sensor[tensorflow] # install tensorflow related dependency
pip install tensor-sensor[jax] # install jax, jaxlib
pip install tensor-sensor[all] # install tensorflow, pytorch, jax
```

which gives you module `tsensor`

. I developed and tested with the following versions

```
$ pip list | grep -i flow
tensorflow 2.5.0
tensorflow-estimator 2.5.0
$ pip list | grep -i numpy
numpy 1.19.5
numpydoc 1.1.0
$ pip list | grep -i torch
torch 1.10.0
torchvision 0.10.0
$ pip list | grep -i jax
jax 0.2.20
jaxlib 0.1.71
```

For displaying abstract syntax trees (ASTs) with `tsensor.astviz(...)`

, you need the `dot`

executable from graphviz, not just the python library.

On **Mac**, do this before or after tensor-sensor install:

```
brew install graphviz
```

On **Windows**, apparently you need

```
conda install python-graphviz # Do this first; get's dot executable and py lib
pip install tensor-sensor # Or one of the other installs
```

I rely on parsing lines that are assignments or expressions only so the clarify and explain routines do not handle methods expressed like:

```
def bar(): b + x * 3
```

Instead, use

```
def bar():
b + x * 3
```

watch out for side effects! I don't do assignments, but any functions you call with side effects will be done while I reevaluate statements.

Can't handle `\`

continuations.

With Python `threading`

package, don't use multiple threads calling clarify(). `multiprocessing`

package should be fine.

Also note: I've built my own parser to handle just the assignments / expressions tsensor can handle.

```
$ python setup.py sdist upload
```

Or download and install locally

```
$ cd ~/github/tensor-sensor
$ pip install .
```

- can i call pyviz in debugger?

Popular Tensorflow Projects

Popular Pytorch Projects

Popular Machine Learning Categories

Related Searches

Get A Weekly Email With Trending Projects For These Categories

No Spam. Unsubscribe easily at any time.

Python

Jupyter Notebook

Deep Learning

Pytorch

Tensorflow

Sensor

Matrix

Vector

Numpy

Shape

Tracing

Tensor