Pytorch-lightning: AttributeError: module 'pytorch_lightning' has no attribute 'TrainResult'

Created on 14 Aug 2020  ·  7Comments  ·  Source: PyTorchLightning/pytorch-lightning

🐛 Bug

Following https://pytorch-lightning.readthedocs.io/en/latest/new-project.html
I tried to log loss values to Tensorboard:

def training_step(self, batch, batch_idx):
loss = ...
result = pl.TrainResult(minimize=loss)
result.log('train_loss', loss)
return result

It seems module "TrainResult" is not present in pytorch-lighting, I'm using latest version (0.8.5)

After browsing various github and SO issues I tried
import TrainResult from pytorch_lightning

but it still doesn't work

To Reproduce

Just follow example in https://pytorch-lightning.readthedocs.io/en/latest/new-project.html

def training_step(self, batch, batch_idx):
loss = ...
result = pl.TrainResult(minimize=loss)
result.log('train_loss', loss)
return result

Expected behavior

I expect code sample in documentation to work (not crash when importing a pytorch-lightning module)

Environment

  • PyTorch Version (e.g., 1.0): 1.5.0
  • OS (e.g., Linux): linux
  • How you installed PyTorch (conda, pip, source): pip
  • Build command you used (if compiling from source): N/A
  • Python version: 3.6.9
  • CUDA/cuDNN version: docker image nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04
  • GPU models and configuration: Nvidia GTI 1080
bug / fix help wanted

All 7 comments

Hi! thanks for your contribution!, great first issue!

import pytorch_lightning as pl
pl.TrainResult
--> fails

from pytorch_lightning import Trainer, TrainResult
--> fails

Same for pytorch-lightning 8.4 and 8.3
Seems fixed on 0.9.0rc12

it's a new feature of 0.9.0 not available before

@williamFalcon
hello, ok, however may I suggest to version differently https://pytorch-lightning.readthedocs.io documentation?

At the moment default homepage is https://pytorch-lightning.readthedocs.io/en/latest/
Since it seems pytorch lightning team uses "latest" as "real latest" and not "latest stable version", it means the default documentation content presented by Google may significantly differ from what's possible in the version one might install by default from Pypi (which would be the latest stable version for production-oriented people like me, which is the version displayed on pypi pytorch-lightning homepage)

where is this link set in the homepage?

https://pypi.org/project/pytorch-lightning/
https://pytorch-lightning.readthedocs.io/en/latest/. --> referenced on above link

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anthonytec2 picture anthonytec2  ·  3Comments

as754770178 picture as754770178  ·  3Comments

mmsamiei picture mmsamiei  ·  3Comments

DavidRuhe picture DavidRuhe  ·  3Comments

srush picture srush  ·  3Comments