Giter Club home page Giter Club logo

tnt's Introduction

TNT

TNT is a library for PyTorch training tools and utilities.

build status pypi version pypi version pypi nightly version codecov bsd license documentation status

Installation

TNT can be installed with pip:

pip install torchtnt

Or, alternatively, via conda:

conda install -c conda-forge torchtnt

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

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

pip install git+https://github.com/pytorch/tnt.git@master

To update to the latest version from master:

pip install --upgrade git+https://github.com/pytorch/tnt.git@master

tnt's People

Contributors

alexandersax avatar amdegroot avatar ananthsub avatar chsasank avatar dahsh avatar daniellepintz avatar diego-urgell avatar edward-io avatar facebook-github-bot avatar fnz avatar galrotem avatar gunchu avatar gwenzek avatar hanmingxuan241 avatar jiaming-liu avatar jksenthil avatar lucasllc avatar malfet avatar ninginthecloud avatar pivovara avatar rohan-varma avatar saumishr avatar schwarzmx avatar shubhamjain0594 avatar soumith avatar srivasv avatar szagoruyko avatar wandering007 avatar williamhufb avatar yhcharles avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tnt's Issues

Releasing TNT v1.0.0

What do you guys think about releasing a stable version of TNT? @szagoruyko @barrykui
I use TNT a lot in my own research, but custom versions that fit my projects. It might make sense to release a flexible, stable version that folks can extend. It might also make it easier for people to contribute to TNT.

Regarding visualization and metrics:

Some example of what I personally might like to see is:

  • A flexible way of dumping results to meters.
  • Using meters to serialize results to disk and to log to Visdom

MeterLogger is a great idea, and I think that we could probably factor it into a MeterStorage class and then a VisdomMeterLogger class and also a FileMeterLogger class.

Engines

Is anything happening with engines? Is this a big use case for TNT users? It seems that pytorch/ignite has similar classes, but I'm not very familiar with them.

I don't have a very strong opinion on this, but if people are not very interested in the engines then it might be useful to drop support for them and to instead focus on I/O and metrics.

Duplicate classes for Datasets

We have two base classes for datasets both in pytorch and torchnet.

  1. torch.utils.data.Dataset
  2. tochnet.dataset.Dataset

This is also the case for TensorDataset. This is potentially confusing for a new user. I had to look up the code to see if there's any relation or difference between the two versions.

My proposal for solving this is:

  1. Use torch.utils.data.Dataset as baseclass for all the datasets in tnt. This might mean foregoing of batch, transform etc. methods, but I think they're actually confusing anyway.
  2. Copy the code tochnet.dataset.TensorDataset to torch.utils.data.TensorDataset and ditch tochnet.dataset.TensorDataset

Sasank.

Incorrect documentation for ConfusionMeter

It says here:

It does not support multi-label, multi-class problems: for such problems, please use MultiLabelConfusionMeter.

Actually, there is no MultiLabelConfusionMeter class implemented in pytorch yet.

AverageValueMeter returns incorrect results when `tensor` is passed

Based on this thread it seems as if the internal members of the class hold references to the tensors, thus yielding wrong results.
When the tensor value is passed by .item() the result is correct.
A simple fix would be to add this condition to add:

def add(self, value, n=1):
    if isinstance(value, torch.Tensor):
        value = value.item()
    self.val = value

I can submit a PR, if that makes sense to you.

Multiple tabs and spaces inconsistencies

I solved this for myself by running autopep8 on my fork; not sure how best to handle.

    if hasattr(torch, "arange"):
                                ^
TabError: inconsistent use of tabs and spaces in indentation

and #50

Histograms fail with "TypeError: histogram() got multiple values for argument 'win'"

 File "/Volumes/ShareData/Projects/gantoolbox/gantoolbox/engines/logging.py", line 38, in write_to_logs
    logger.log(state['g_iters'], value)
  File "/Volumes/home500/anaconda/envs/pytorch/lib/python3.5/site-packages/torchnet/logger/visdomlogger.py", line 105, in log
    self.viz_logger(*args, **kwargs)
  File "/Volumes/home500/anaconda/envs/pytorch/lib/python3.5/site-packages/torchnet/logger/visdomlogger.py", line 47, in _viz_logger
    **kwargs)
  File "/Volumes/home500/anaconda/envs/pytorch/lib/python3.5/site-packages/visdom/__init__.py", line 190, in result
    return fn(*args, **kwargs)
TypeError: histogram() got multiple values for argument 'win'

value is confirmed to be a 1-D FloatTensor on CPU.

The logger is created with:

tnt.logger.VisdomLogger('histogram', opts=dict(
            title=title,
            numbins=100
        ))

(Also I note there's a bug in the histogram example in visdomlogger.py, an extra , when the logger is created.)

Logger + JSON

I suggest adding an option to use the logger to save to JSON files.

AverageValueMeter is unstable when the variance is very small

The implementation of the standard-deviation calculation in torchnet.meter.AverageValueMeter is numerically unstable and can lead to a negative value of the variance (line 23: (self.var - n * mean * mean) / (n - 1.0)). This negative value triggers a "ValueError: math domain error" exception when we try to take the square-root of it.

The reason is explained well by John D. Cook in his blog post: https://www.johndcook.com/blog/standard_deviation/

Specifically, Mr. Cook says: “If the x‘s are large and the differences between them small, direct evaluation of the equation above would require computing a small number as the difference of two large numbers, a red flag for numerical computing. The loss of precision can be so bad that the expression above evaluates to a negative number even though variance is always positive.”

I’ve created a test case (attached) showing an example where the calculation of the standard deviation triggers an exception when a negative variance is used to calculate the standard deviation.
I’ve also created a fix, based on John D. Cook’s implementation of B.P. Welford’s variance computation algorithm, which is attached. The credit goes entirely to Mr. Cook, as I used his implementation. I even preserved his variable naming, although I made one small change: instead of using m_oldS and m_newS, I used one variable (m_S) because there is no need for two variables.
test.py.txt

I'm using Python 2.7.12, Pytorch 0.2.0_3

Thanks!
Neta

PyTorch 0.4 test errors

Need to fix these:

..........
----------------------------------------------------------------------
Ran 10 tests in 0.015s

OK
E.../Users/szagoruyko/anaconda3/lib/python3.6/site-packages/numpy/core/_methods.py:135: RuntimeWarning: Degrees of freedom <= 0 for slice
  keepdims=keepdims)
/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/numpy/core/_methods.py:127: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
.....E
======================================================================
ERROR: testAPMeter (__main__.TestMeters)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_meters.py", line 208, in testAPMeter
    ap = mtr.value()
  File "/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/torchnet/meter/apmeter.py", line 137, in value
    ap[k] = precision[truth.byte()].sum() / max(truth.sum(), 1)
RuntimeError: Expected object of type torch.FloatTensor but found type torch.LongTensor for argument #2 'other'

======================================================================
ERROR: testmAPMeter (__main__.TestMeters)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_meters.py", line 329, in testmAPMeter
    ap = mtr.value()
  File "/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/torchnet/meter/mapmeter.py", line 30, in value
    return self.apmeter.value().mean()
  File "/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/torchnet/meter/apmeter.py", line 137, in value
    ap[k] = precision[truth.byte()].sum() / max(truth.sum(), 1)
RuntimeError: Expected object of type torch.FloatTensor but found type torch.LongTensor for argument #2 'other'

----------------------------------------------------------------------
Ran 10 tests in 0.118s

FAILED (errors=2)

BatchDataset cannot handle arguments from tuple

Hi,

I tried to use BatchDataset to concatenate the outputs, tuple with features, labels, etc., from my dataset but it seems that I should pack them inside a dictionary otherwise, this line will produce an error.
It would be cool to say that in the documentation or provide support for iterable like tuple and list.

P.D. Thanks for providing this awesome set of tools.

No documentation on how to update your version of torchnet

Apparently, the repo wiki only lists how to install torchnet, however, there's no way documented on how to incorporate updates that have been done in the main repository. It would be convenient if you could add how to especially for people who use torchnet for their work but haven't had a lot of experience with version control or git.

Error message "'>' not supported between instances of 'float' and 'NoneType'"

I introducted TNT into my pure-PyTorch Project, but right now I'm getting the following warnings while training

...
'>' not supported between instances of 'float' and 'NoneType'
...

It does not seem to have any effect on my meters though.

The lines I'm using from TNT are:

mlog = MeterLogger(server='127.0.0.1', port=8097, nclass=2, title="Part-Logger")
...
mlog.update_loss(loss.cpu(), meter='loss')
mlog.update_meter(outputs[0].cpu(), labels.cpu(), meters={'accuracy', 'confusion'})
...
mlog.print_meter(mode="Train", iepoch=epoch)
mlog.reset_meter(mode="Train", iepoch=epoch)

Where the parameters might look like this:

> loss.cpu()
[1], dtype=float32

> outputs[0].cpu().shape
[20, 2], dtype=float32

> labels.cpu().shape
[20], dtype=int32

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',))

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

How I can fix this connection error?

Exception in user code:

Traceback (most recent call last):
File "/home/deepak/softwares/miniconda3/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/home/deepak/softwares/miniconda3/lib/python3.6/site-packages/urllib3/util/connection.py", line 83, in create_connection
raise err
File "/home/deepak/softwares/miniconda3/lib/python3.6/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

Inconsistent AverageValueMeter behaviour

Hello.
There is some strange behavior in AverageValueMeter. Both of tests below are failing with big difference in values:

import numpy as np
from torchnet.meter import AverageValueMeter

def test_tnt_meter_mean():

    values = np.random.rand(1000)
    
    meter = AverageValueMeter()
    meter.add(values[0])
    
    for i in range(1, len(values)):
        meter.add(values[i])
        
        met_mean = meter.value()[0]

        print(i)
        assert met_mean == values[:i+1].mean()


def test_tnt_meter_std():
    values = np.random.rand(1000)

    meter = AverageValueMeter()
    meter.add(values[0])

    for i in range(1, len(values)):
        meter.add(values[i])

        met_std = meter.value()[1]

        print(i)
        assert met_std == values[:i+1].std()

I understand that this may be intentional, but it's not documented and not what is usually expected by default from class with Average in it's name.

updateTrace() problem

This obviously gives an error

        self.viz.updateTrace(X=np.array([x]), Y=np.array([y]), env=self.env, win=self.plots[var_name], name=split_name)

How on earth do i port this to the newer vizdom API?

PEP8 compliance?

I notice sometimes snake_case, sometimes mixedCase are used for class methods

def on_end_epoch(state):
        mlog.printMeter(mode="Train", iepoch=state['epoch'])
        mlog.resetMeter(mode="Train", iepoch=state['epoch'])

WIll tnt codebase 100% comply with PEP8?

memory leaky on engine.test

  • OS: Ubuntu16.04
  • PyTorch version: 0.3.1
  • PyTorchNet version: 0.0.1
  • How you installed PyTorch (conda, pip, source): conda
  • Python version: 3.6.4
  • CUDA/cuDNN version: CUDA 9.0.176/cuDNN 7.0.5.15

The script to reproduce the bug:

from torch import nn
from torch.autograd import Variable
from torch.optim import Adam
from torchnet.engine import Engine
from tqdm import tqdm
import torchvision.transforms as transforms
from torch.utils.data import DataLoader
from torchvision.datasets import MNIST

class MNISTNet(nn.Module):
    def __init__(self):
        super(MNISTNet, self).__init__()
        self.features = nn.Sequential(
            nn.Conv2d(in_channels=1, out_channels=64, kernel_size=7, stride=2, padding=3),
            nn.Conv2d(in_channels=64, out_channels=128, kernel_size=3, stride=2, padding=1),
            nn.Conv2d(in_channels=128, out_channels=256, kernel_size=3, stride=2, padding=1),
            nn.Conv2d(in_channels=256, out_channels=512, kernel_size=3, stride=2, padding=1),
            nn.Conv2d(in_channels=512, out_channels=512, kernel_size=3, stride=1, padding=1)
        )
        self.classifier = nn.Linear(in_features=2 * 2 * 512, out_features=10)

    def forward(self, x):
        out = self.features(x)
        out = out.view(out.size(0), -1)
        classes = self.classifier(out)
        return classes


def get_iterator(mode):
    data = MNIST(root='./', train=mode, transform=transforms.ToTensor(), download=True)
    return DataLoader(dataset=data, batch_size=64, shuffle=mode, num_workers=4)


def processor(sample):
    data, labels, training = sample
    data = Variable(data).cuda()
    labels = Variable(labels).cuda()
    classes = model(data)
    loss = loss_criterion(classes, labels)
    return loss, classes


def on_sample(state):
    state['sample'].append(state['train'])


def on_start_epoch(state):
    state['iterator'] = tqdm(state['iterator'])


def on_end_epoch(state):
    engine.test(processor, get_iterator(False))


if __name__ == '__main__':

    model = MNISTNet().cuda()
    loss_criterion = nn.CrossEntropyLoss().cuda()

    optimizer = Adam(model.parameters())
    engine = Engine()
    engine.hooks['on_sample'] = on_sample
    engine.hooks['on_start_epoch'] = on_start_epoch
    engine.hooks['on_end_epoch'] = on_end_epoch

    engine.train(processor, get_iterator(True), maxepoch=100, optimizer=optimizer)

Error messages

  • on epoch 1, before on_end_epoch:
    screenshot from 2018-03-15 20-23-31
  • after on_end_epoch, you could see the memory is grow up to about 3 times:
    screenshot from 2018-03-15 20-24-00

Preference: PyTorch Tensors or Numpy Arrays

I have ported over a few more of the lua torchnet meters and would like to make a PR, but I am curious as to whether I should check inputs and convert to pytorch tensors or check inputs and convert to numpy arrays? I see more cases of the latter, but my meters are currently using pytorch tensors and resizing tensor storage in meter.add() as many of the lua meters do.

AUCMeter return value is inconsistent

Hi!
AUCMeter normally returns a tuple of (area, tpr, fpr). However, if no data has been added to the meter, it only returns 0.5. It would be nice if AUCMeter would always return a tuple, i.e., that in the case of an empty meater it would return something like (0.5, [], []). Otherwise one always has to check if the return value is a tuple or not.

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.

Feature-Request: Ability to save metric-values

It might be useful to be able to save the metrics to files, in order to be able to use them somewhere else for e.g. visualisation.

I'm thinking about something like:

mlog.save_meter(dir='train_metrics', meters={'loss':'loss.csv', 'accuracy':'accuracy.csv', 'confusion':'confusion.csv'})

For me that would be really beneficial, what do you think about it?

Incorrect assertation in torchnet/meter/confusionmeter.py

Incorrect assertation will shown when the target shape is 1 (means only one input per batch).

line43-44:
assert predicted.shape[0] == target.shape[0],
'number of targets and predicted outputs do not match'

Example:
image

this will cause an error in my program

Multiple hooks on the same event

Would it be better if there can be multiple hooks bound to the same event? This would prevent the need to create a meta-hook for all hooks that need to be bound a particular event.

Also what is the relationship between this repo and the trainer class in pytorch?

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

Incorrect documentation for APMeter

https://github.com/pytorch/tnt/blob/master/torchnet/meter/apmeter.py#L36-L37 states
The probabilities should sum to one over all classes, which is not a requirement. If multiple classes are present in an image, we would want our method to produce high confidences for each and each confidence is in the [0, 1] range. I don't think normalizing scores across classes would make much sense.

The rest of the implementation doesn't seem to be making use of this requirement.

ROC-AUC doesn't reproduce the same value as sklearn.metrics.roc_auc_score

here is a sample code to reproduce:

    y_pred = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0],
                   [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0],
                   [1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],
                   [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0],
                   [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]])

    y_true = np.array([[0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0],
                       [1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
                       [1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],
                       [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0],
                       [0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]])
    y_pred = y_pred.reshape([-1])
    y_true = y_true.reshape([-1])
    aucmeter = AUCMeter()
    aucmeter.add(y_pred, y_true)
    print(aucmeter.value()[0], sklearn.metrics.roc_auc_score(y_true,y_pred))

the data sample is not the best to measure an AUC for a ROC but is should reproduce the same result

printMeter works incorrectly due to wrong indent

MeterLogger.printMeter can't print desire information because of a logical error caused by wrong indent.

Currently it can only print the default 'loss' meter.

Below is the source of the function.

(starts from line 123 in meterlogger.py

def print_meter(self, mode, iepoch, ibatch=1, totalbatch=1, meterlist=None):
    pstr = "%s:\t[%d][%d/%d] \t"
    tval = []
    tval.extend([mode, iepoch, ibatch, totalbatch])
    if meterlist is None:
        meterlist = self.meter.keys()
        for meter in meterlist:
            if meter in ['confusion', 'histogram', 'image']:
                continue
            if meter == 'accuracy':
                pstr += "Acc@1 %.2f%% \t Acc@" + str(self.topk) + " %.2f%% \t"
                tval.extend([self.meter[meter].value()[0], self.meter[meter].value()[1]])
            elif meter == 'map':
                pstr += "mAP %.3f \t"
                tval.extend([self.meter[meter].value()])
            elif meter == 'auc':
                pstr += "AUC %.3f \t"
                tval.extend([self.meter[meter].value()])
            else:
                pstr += meter + " %.3f (%.3f)\t"
                tval.extend([self.meter[meter].val, self.meter[meter].mean])
                pstr += " %.2fs/its\t"
                tval.extend([self.timer.value()])
                print(pstr % tuple(tval))

I think the error comes from commit 7b1dc6c when formatting.

image

py3.5 travis tests fail non-deterministically

very odd, sometimes py3.5 bugs out on splitdataset, 3.6 is fine:

======================================================================
FAIL: testSplitDataset (__main__.TestDatasets)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_datasets.py", line 102, in testSplitDataset
    self.assertEqual(splitdataset[2], 2)
AssertionError: 3 != 2

======================================================================
FAIL: testSplitDataset_fractions (__main__.TestDatasets)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_datasets.py", line 122, in testSplitDataset_fractions
    self.assertEqual(splitdataset[2], 2)
AssertionError: 3 != 2

----------------------------------------------------------------------
Ran 10 tests in 0.003s

visdomlogger.py fails because of Visdom.updateTrace() removal

Commit bfbe7a79a19caaabf6b93ef6488b3185cf889e1c removed Visdom.updateTrace()

fossasia/visdom@5e1a28f

This causes the visdomlogger.py to fail.

in plot(self, x, y)
51
52 def plot(self, x, y):
---> 53 self.avg_train_loss_logger.log(x, y)
54
55 def record(self, e, loss):

/usr/local/lib/python3.6/dist-packages/torchnet/logger/visdomlogger.py in log(self, *args, **kwargs)
157 # For some reason, the first point is a different trace. So for now
158 # we can just add the point again, this time on the correct curve.
--> 159 self.log(*args, **kwargs)
160
161

/usr/local/lib/python3.6/dist-packages/torchnet/logger/visdomlogger.py in log(self, *args, **kwargs)
137 type(self)))
138 x, y = args
--> 139 self.viz.updateTrace(
140 X=np.array([x]),
141 Y=np.array([y]),

AttributeError: 'Visdom' object has no attribute 'updateTrace'`

Unable to install

On running pip install torchnet in python2.7 environment I get

Collecting torchnet
  Could not find a version that satisfies the requirement torchnet (from versions: )
No matching distribution found for torchnet

Pytorch is installed in the environment.

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!

VisdomLogger username and password configration

At the moment it is not possible to configure the Visdom client with a username & password. Making it impossible to use this repo when you have a visdom server with auth enabled.

I'll gladly submit a PR with this feature if you think this is something you would accept.

The implementation would be passing username and password from the logger classes until it gets to visdom.Visdom, like:

self._viz = visdom.Visdom(
    server="http://" + server,
    port=port,
    username=user,
    password=pass
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.