timeseriesAI / tsai

Time series Timeseries Deep Learning Machine Learning Python Pytorch fastai | State-of-the-art Deep Learning library for Time Series and Sequences in Pytorch / fastai
https://timeseriesai.github.io/tsai/
Apache License 2.0
4.92k stars 622 forks source link

Error: graph_out is 'NoneType' which has no attribute 'update'! #838

Open Melmaphother opened 9 months ago

Melmaphother commented 9 months ago

When I run the first demo 'Binary univariate classification', I find that in line 8: 'clf.fit_one_cycle(100, 3e-4)', the intepreter notices an error: 'graph_out is 'NoneType' which has no attribute 'update''. Thanks to the debugging mode in Pycharm, I find the variation 'graph_out' in file 'core.py'. It first appears at line 106: 'self.graph_out = display(self.graph_ax.figure, display_id=True)' while last appears at line 117 'if not self.graph_out==None: self.graph_out.update(self.graph_ax.figure)' which is the source of the error. The reason of 'graph_out' seems to be 'Nonetype' is that in the function 'display' which is in file 'display_functions.py', if 'not InteractiveShell.initialized()'(line 263), the function 'display' will return None(line 266). As a result,in some cases, the variation 'graph_out' will be None.Unfortunately, is will be transfered soon at line 117 in file 'core.py' and this will cause the error. I suggest to add an examination 'if self.graph_out is not None:' before the transfer of 'graph_out'.

nhansendev commented 5 months ago

This error is appears when the example code is not run in a jupyter Notebook. It is implied, but not explicitly stated that the code should be run in a notebook (I think it could be clearer).

If you want to run the code without a notebook, but without graphs you can remove the ShowGraph() part of the TSClassifier definition in the example (or set the "cbs" kwarg to None):

  clf = TSClassifier(X, y, splits=splits, path='models', arch="InceptionTimePlus", tfms=tfms, batch_tfms=batch_tfms, metrics=accuracy) #, cbs=ShowGraph())

I'm not familiar enough with the library to suggest how to re-add graphing outside of a notebook as there may be a built-in option for it.

Melmaphother commented 5 months ago

Thanks for your answer, I'll use jupyter Notebook to try it again.