Folks using Jupyter might find this handy.
I’m the author of a utility called
matrepr ( matrepr · PyPI ) that can pretty-format sparse and dense tensors to string, HTML, and Latex, with Jupyter integration.
PyTorch’s native string repr works well for dense tensors, but less so for sparse tensors where one must manually decode the internal arrays. MatRepr will pretty-print to a nice 2D matrix, or a coordinates+value tuple if more than 2 dimensions. Hybrid tensors are also supported. CSR/CSC are explicitly decoded so the output is instantaneous no matter how large the tensors are.
See a demo comparing native repr with MatRepr on several types of tensors at Jupyter Notebook Viewer