Simple tools for logging and visualizing, loading and training

Overview

TNT

TNT is a library providing powerful dataloading, logging and visualization utilities for Python. It is closely integrated with PyTorch and is designed to enable rapid iteration with any model or training regimen.

travis Documentation Status

Installation

TNT can be installed with pip. To do so, run:

pip install torchnet

If you run into issues, make sure that Pytorch is installed first.

You can also install the latest verstion from master. Just run:

pip install git+https://github.com/pytorch/[email protected]

To update to the latest version from master:

pip install --upgrade git+https://github.com/pytorch/[email protected]

About

TNT (imported as torchnet) is a framework for PyTorch which provides a set of abstractions for PyTorch aiming at encouraging code re-use as well as encouraging modular programming. It provides powerful dataloading, logging, and visualization utilities.

The project was inspired by TorchNet, and legend says that it stood for “TorchNetTwo”. Since the deprecation of TorchNet TNT has developed on its own.

For example, TNT provides simple methods to record model preformance in the torchnet.meter module and to log them to Visdom (or in the future, TensorboardX) with the torchnet.logging module.

In the future, TNT will also provide strong support for multi-task learning and transfer learning applications. It currently supports joint training data loading through torchnet.utils.MultiTaskDataLoader.

Most of the modules support NumPy arrays as well as PyTorch tensors on input, and so could potentially be used with other frameworks.

Getting Started

See some of the examples in https://github.com/pytorch/examples. We would like to include some walkthroughs in the docs (contributions welcome!).

[LEGACY] Differences with lua version

What's been ported so far:

  • Datasets:
    • BatchDataset
    • ListDataset
    • ResampleDataset
    • ShuffleDataset
    • TensorDataset [new]
    • TransformDataset
  • Meters:
    • APMeter
    • mAPMeter
    • AverageValueMeter
    • AUCMeter
    • ClassErrorMeter
    • ConfusionMeter
    • MovingAverageValueMeter
    • MSEMeter
    • TimeMeter
  • Engines:
    • Engine
  • Logger
    • Logger
    • VisdomLogger
    • MeterLogger [new, easy to plot multi-meter via Visdom]

Any dataset can now be plugged into torch.utils.DataLoader, or called .parallel(num_workers=8) to utilize multiprocessing.

Comments
  • Cleanup PT-D imports

    Cleanup PT-D imports

    Summary: The flow logic around torch.dist imports results in large number of pyre errors; would be preferable to just raise on importing as opposed to silently fail to import bindings.

    Cons: Some percentage (MacOS?) of users may have notebooks that imports pytorch.distributed, although would think small, since any attempt to call parts of the library would just fail...

    fb: TODO: assuming ok, will remove the 10's-100's of unused pyre ignores no longer required.

    Differential Revision: D39842273

    cla signed fb-exported Reverted 
    opened by dstaay-fb 10
  • Add more datasets

    Add more datasets

    Added:

    • SplitDataset
    • ConcatDataset

    Made load an optional parameter in ListDataset so that it can be used as TableDataset.

    Added seed to resample in ShuffleDataset

    I don't understand why elem_list has to torch.LongTensor if tensor in ListDataset (see here). It seems pointless.

    Sasank.

    opened by chsasank 8
  • Update the train() API parameter to take a state

    Update the train() API parameter to take a state

    Summary: Allow the states to be set up outside of the train() function, provides better flexibility. However, the state becomes an opaque object that might be modified accidentally.

    Suggest, we should move dataloader out of the state. and make the state immutable.

    Reviewed By: ananthsub

    Differential Revision: D40233501

    cla signed fb-exported 
    opened by zzzwen 7
  • Fix tests for CI

    Fix tests for CI

    Summary: Seeing errors like this in CI on trunk:

        from torchtnt.tests.runner.utils import DummyPredictUnit, generate_random_dataloader
    E   ModuleNotFoundError: No module named 'torchtnt.tests'
    

    moving the test utils to resolve it

    Differential Revision: D38774677

    cla signed fb-exported 
    opened by ananthsub 6
  • I found it would be failed when initialize MeterLogger server with `http://` head.

    I found it would be failed when initialize MeterLogger server with `http://` head.

    i found it would be failed when initialize MeterLogger server with http:// head.

    >>> a = MeterLogger(server="http://localhost", port=8097, env='hello')
    >>> b = torch.Tensor([1])
    >>> a.updateLoss(b, 'loss')
    >>> a.resetMeter(mode='Train', iepoch=1)
    

    Error message here

    Exception in user code:
    ------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/txk/.local/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
        (self.host, self.port), self.timeout, **extra_kw)
      File "/home/txk/.local/lib/python3.6/site-packages/urllib3/util/connection.py", line 60, in create_connection
        for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
      File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
        for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    socket.gaierror: [Errno -2] Name or service not known
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/txk/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
        chunked=chunked)
      File "/home/txk/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 357, in _make_request
        conn.request(method, url, **httplib_request_kw)
      File "/usr/lib/python3.6/http/client.py", line 1239, in request
        self._send_request(method, url, body, headers, encode_chunked)
      File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
        self.endheaders(body, encode_chunked=encode_chunked)
      File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
        self._send_output(message_body, encode_chunked=encode_chunked)
      File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
        self.send(msg)
      File "/usr/lib/python3.6/http/client.py", line 964, in send
        self.connect()
      File "/home/txk/.local/lib/python3.6/site-packages/urllib3/connection.py", line 166, in connect
        conn = self._new_conn()
      File "/home/txk/.local/lib/python3.6/site-packages/urllib3/connection.py", line 150, in _new_conn
        self, "Failed to establish a new connection: %s" % e)
    urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f6cc08ce198>: Failed to establish a new connection: [Errno -2] Name or service not known
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/txk/.local/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
        timeout=timeout
      File "/home/txk/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
        _stacktrace=sys.exc_info()[2])
      File "/home/txk/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
        raise MaxRetryError(_pool, url, error or ResponseError(cause))
    urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='http', port=80): Max retries exceeded with url: //localhost:8097/events (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6cc08ce198>: Failed to establish a new connection: [Errno -2] Name or service not known',))
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/txk/.local/lib/python3.6/site-packages/visdom/__init__.py", line 261, in _send
        data=json.dumps(msg),
      File "/home/txk/.local/lib/python3.6/site-packages/requests/api.py", line 112, in post
        return request('post', url, data=data, json=json, **kwargs)
      File "/home/txk/.local/lib/python3.6/site-packages/requests/api.py", line 58, in request
        return session.request(method=method, url=url, **kwargs)
      File "/home/txk/.local/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
        resp = self.send(prep, **send_kwargs)
      File "/home/txk/.local/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
        r = adapter.send(request, **kwargs)
      File "/home/txk/.local/lib/python3.6/site-packages/requests/adapters.py", line 508, in send
        raise ConnectionError(e, request=request)
    requests.exceptions.ConnectionError: HTTPConnectionPool(host='http', port=80): Max retries exceeded with url: //localhost:8097/events (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6cc08ce198>: Failed to establish a new connection: [Errno -2] Name or service not known',))
    
    
    opened by TuXiaokang 6
  • Some code format error exists in `meterlogger.py`

    Some code format error exists in `meterlogger.py`

    error message like this

    >>> import torchnet
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python3.6/site-packages/torchnet/__init__.py", line 5, in <module>
        from . import logger
      File "/usr/local/lib/python3.6/site-packages/torchnet/logger/__init__.py", line 2, in <module>
        from .meterlogger import MeterLogger
      File "/usr/local/lib/python3.6/site-packages/torchnet/logger/meterlogger.py", line 16
        self.nclass = nclass
                           ^
    TabError: inconsistent use of tabs and spaces in indentation
    
    opened by TuXiaokang 6
  • Add Visdom logging to TNT

    Add Visdom logging to TNT

    Added the ability to log to Visdom (like Tensorboard, but better!). It is a port of this repo to TNT.

    screen shot 2017-08-03 at 3 27 10 pm

    This PR adds TNT support for the existing Visdom plots and includes an example that uses it for MNIST (above).

    opened by alexsax 6
  • how to use conda install torchnet?

    how to use conda install torchnet?

    In my ubuntu sever, pip is ok, but torchnet is only in 'pip list' and not in 'conda list', so when i run xx.py, error is no module named 'torchnet'. So i want to ask if i can use conda to install torchnet and how to install it? could anyone help me? thanks!

    opened by qilong-zhang 5
  • Replace loss[0] with loss.item() due to deprecation

    Replace loss[0] with loss.item() due to deprecation

    When using tnt's meterlogger a deprecation warning by PyTorch does appear:

    UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.
    5. Use tensor.item() to convert a 0-dim tensor to a Python number
    

    Issued by this line.

    Replacing loss[0] with loss.item() should fix that without any further consequences

    opened by sauercrowd 5
  • Generic tnt.Engine?

    Generic tnt.Engine?

    Shouldn't the tnt.engine.Engine be changed to tnt.engine.SGDEngine and tnt.engine.Engine be a generic engine?

    This is similar to torchnet which allowed extending engines to make meta-engines like train_val_engine.

    opened by karandwivedi42 5
  • Update LRScheduler instance checks

    Update LRScheduler instance checks

    Summary: After https://github.com/pytorch/pytorch/pull/88503 , these isinstance checks no longer pass. Example: https://github.com/pytorch/tnt/actions/runs/3434539858/jobs/5725945075

    Differential Revision: D41177335

    cla signed fb-exported 
    opened by ananthsub 4
  • Create torchtnt.utils.lr_scheduler.TLRScheduler

    Create torchtnt.utils.lr_scheduler.TLRScheduler

    Summary:

    Introduce torchtnt.utils.lr_scheduler.TLRScheduler to manage compatibility of torch with expose of LRScheduler https://github.com/pytorch/pytorch/pull/88503

    It seems that issue persist still with 1.13.1 (see #285). Replace the get_version logic with try/except. _LRscheduler.

    Fixes #285 https://github.com/pytorch/tnt/issues/285

    cla signed 
    opened by dmtrs 7
  • Issue with torch 1.13

    Issue with torch 1.13

    🐛 Describe the bug

    Can not import torchtnt.framework due to AttributeError.

    Traceback (most recent call last):
      File "/Users/foo/app/runner/trainer/__init__.py", line 4, in <module>
        import torchtnt.framework
      File "/Users/foo/Library/Caches/pypoetry/virtualenvs/sp-mcom8aNU-py3.9/lib/python3.9/site-packages/torchtnt/framework/__init__.py", line 7, in <module>
        from .auto_unit import AutoUnit
      File "/Users/foo/Library/Caches/pypoetry/virtualenvs/sp-mcom8aNU-py3.9/lib/python3.9/site-packages/torchtnt/framework/auto_unit.py", line 23, in <module>
        from torchtnt.framework.unit import EvalUnit, PredictUnit, TrainUnit
      File "/Users/foo/Library/Caches/pypoetry/virtualenvs/sp-mcom8aNU-py3.9/lib/python3.9/site-packages/torchtnt/framework/unit.py", line 24, in <module>
        TLRScheduler = torch.optim.lr_scheduler.LRScheduler
    AttributeError: module 'torch.optim.lr_scheduler' has no attribute 'LRScheduler'
    

    From torch documentation it does not seem to have a torch.optim.lr_scheduler in stable version. https://pytorch.org/docs/stable/optim.html. Please also see BC-breaking change after 1.10 that may affect optimizer and lr step.

    From requirements.txt it does not seem this is locked in particular torch version.

    What is current working supported torch version for torchtnt=0.0.4? Is there plans to have particular supported torch versions?

    Versions

    % poetry run python collect_env.py                                                                                                                                                                      ✹ ✭
    Collecting environment information...
    PyTorch version: 1.13.1
    Is debug build: False
    CUDA used to build PyTorch: None
    ROCM used to build PyTorch: N/A
    
    OS: macOS 10.14.6 (x86_64)
    GCC version: Could not collect
    Clang version: Could not collect
    CMake version: Could not collect
    Libc version: N/A
    
    Python version: 3.9.13 (main, Sep  3 2022, 22:36:35)  [Clang 10.0.1 (clang-1001.0.46.4)] (64-bit runtime)
    Python platform: macOS-10.14.6-x86_64-i386-64bit
    Is CUDA available: False
    CUDA runtime version: No CUDA
    CUDA_MODULE_LOADING set to: N/A
    GPU models and configuration: No CUDA
    Nvidia driver version: No CUDA
    cuDNN version: No CUDA
    HIP runtime version: N/A
    MIOpen runtime version: N/A
    Is XNNPACK available: True
    
    Versions of relevant libraries:
    [pip3] mypy-extensions==0.4.3
    [pip3] numpy==1.23.5
    [pip3] torch==1.13.1
    [pip3] torchtnt==0.0.4
    [conda] Could not collect
    
    opened by dmtrs 1
  • Support recreating dataloaders during loop

    Support recreating dataloaders during loop

    Summary: Sometimes users need to recreate the dataloaders at the start of the epoch during the overall training loop. To support this, we allow users to register a creation function when creating the state for training or fitting. We pass the state as an argument since users may want to use progress information such as the progress counters to reinitialize the dataloader.

    We don't add this support for evaluate or predict since those functions iterate through the corresponding dataloader just once.

    For fit, this allows flexibility to reload training & evaluation dataloaders independently during if desired

    Differential Revision: D40539580

    cla signed fb-exported 
    opened by ananthsub 3
Releases(0.0.5.1)
Hierarchical Clustering: O(1)-Approximation for Well-Clustered Graphs

Hierarchical Clustering: O(1)-Approximation for Well-Clustered Graphs This repository contains code to accompany the paper "Hierarchical Clustering: O

3 Sep 25, 2022
Parameterising Simulated Annealing for the Travelling Salesman Problem

Parameterising Simulated Annealing for the Travelling Salesman Problem

Gary Sun 55 Jun 15, 2022
Differentiable Neural Computers, Sparse Access Memory and Sparse Differentiable Neural Computers, for Pytorch

Differentiable Neural Computers and family, for Pytorch Includes: Differentiable Neural Computers (DNC) Sparse Access Memory (SAM) Sparse Differentiab

ixaxaar 302 Dec 14, 2022
Official repository of DeMFI (arXiv.)

DeMFI This is the official repository of DeMFI (Deep Joint Deblurring and Multi-Frame Interpolation). [ArXiv_ver.] Coming Soon. Reference Jihyong Oh a

Jihyong Oh 56 Dec 14, 2022
Rank 1st in the public leaderboard of ScanRefer (2021-03-18)

InstanceRefer InstanceRefer: Cooperative Holistic Understanding for Visual Grounding on Point Clouds through Instance Multi-level Contextual Referring

63 Dec 07, 2022
Implementation of the Point Transformer layer, in Pytorch

Point Transformer - Pytorch Implementation of the Point Transformer self-attention layer, in Pytorch. The simple circuit above seemed to have allowed

Phil Wang 501 Jan 03, 2023
For IBM Quantum Challenge 2021 (May 20 - 26)

IBM Quantum Challenge 2021 Introduction Commemorating the 40-year anniversary of the Physics of Computation conference, and 5-year anniversary of IBM

Qiskit Community 140 Jan 01, 2023
Resources related to our paper "CLIN-X: pre-trained language models and a study on cross-task transfer for concept extraction in the clinical domain"

CLIN-X (CLIN-X-ES) & (CLIN-X-EN) This repository holds the companion code for the system reported in the paper: "CLIN-X: pre-trained language models a

Bosch Research 4 Dec 05, 2022
A rough implementation of the paper "A Steering Algorithm for Redirected Walking Using Reinforcement Learning"

A rough implementation of the paper "A Steering Algorithm for Redirected Walking Using Reinforcement Learning"

Somnus `Chen 2 Jun 09, 2022
Fast, modular reference implementation and easy training of Semantic Segmentation algorithms in PyTorch.

TorchSeg This project aims at providing a fast, modular reference implementation for semantic segmentation models using PyTorch. Highlights Modular De

ycszen 1.4k Jan 02, 2023
PyTorch implementation for STIN

STIN This repository contains PyTorch implementation for STIN. Abstract: In single-photon LiDAR, photon-efficient imaging captures the 3D structure of

Yiweins 2 Nov 22, 2022
deep learning model that learns to code with drawing in the Processing language

sketchnet sketchnet - processing code generator can we teach a computer to draw pictures with code. We use Processing and java/jruby code paired with

41 Dec 12, 2022
.NET bindings for the Pytorch engine

TorchSharp TorchSharp is a .NET library that provides access to the library that powers PyTorch. It is a work in progress, but already provides a .NET

Matteo Interlandi 17 Aug 30, 2021
Bonnet: An Open-Source Training and Deployment Framework for Semantic Segmentation in Robotics.

Bonnet: An Open-Source Training and Deployment Framework for Semantic Segmentation in Robotics. By Andres Milioto @ University of Bonn. (for the new P

Photogrammetry & Robotics Bonn 314 Dec 30, 2022
This is the official implementation of VaxNeRF (Voxel-Accelearated NeRF).

VaxNeRF Paper | Google Colab This is the official implementation of VaxNeRF (Voxel-Accelearated NeRF). This codebase is implemented using JAX, buildin

naruya 132 Nov 21, 2022
Context-Aware Image Matting for Simultaneous Foreground and Alpha Estimation

Context-Aware Image Matting for Simultaneous Foreground and Alpha Estimation This is the inference codes of Context-Aware Image Matting for Simultaneo

Qiqi Hou 125 Oct 22, 2022
Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting

Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting This is the origin Pytorch implementation of Informer in the followin

Haoyi 3.1k Dec 29, 2022
An API-first distributed deployment system of deep learning models using timeseries data to analyze and predict systems behaviour

Gordo Building thousands of models with timeseries data to monitor systems. Table of content About Examples Install Uninstall Developer manual How to

Equinor 26 Dec 27, 2022
Code for IntraQ, PyTorch implementation of our paper under review

IntraQ: Learning Synthetic Images with Intra-Class Heterogeneity for Zero-Shot Network Quantization paper Requirements Python = 3.7.10 Pytorch == 1.7

1 Nov 19, 2021
DeepLearning Anomalies Detection with Bluetooth Sensor Data

Final Year Project. Constructing models to create offline anomalies detection using Travel Time Data collected from Bluetooth sensors along the route.

1 Jan 10, 2022