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
5.16k stars 644 forks source link

Import Error in Intro_to_Time_Series_Classification #16

Closed shrimpceviche closed 3 years ago

shrimpceviche commented 4 years ago

Running the import libraries cell would incur the following error

/usr/local/lib/python3.6/dist-packages/tsai/all.py in <module>()
----> 1 from .imports import *
      2 from .utils import *
      3 from .data.all import *
      4 from .metrics import *
      5 from .learner import *

/usr/local/lib/python3.6/dist-packages/tsai/imports.py in <module>()
      1 import fastai2
      2 from fastai2.imports import *
----> 3 from fastai2.data.all import *
      4 from fastai2.torch_core import *
      5 from fastai2.learner import *

/usr/local/lib/python3.6/dist-packages/fastai2/data/all.py in <module>()
      3 from .load import *
      4 from .external import *
----> 5 from .transforms import *
      6 from .block import *

/usr/local/lib/python3.6/dist-packages/fastai2/data/transforms.py in <module>()
    228 
    229 # Cell
--> 230 class Categorize(DisplayedTransform):
    231     "Reversible transform of category string to `vocab` id"
    232     loss_func,order,store_attrs=CrossEntropyLossFlat(),1,'vocab,add_na'

/usr/local/lib/python3.6/dist-packages/fastai2/data/transforms.py in Categorize()
    230 class Categorize(DisplayedTransform):
    231     "Reversible transform of category string to `vocab` id"
--> 232     loss_func,order,store_attrs=CrossEntropyLossFlat(),1,'vocab,add_na'
    233     def __init__(self, vocab=None, sort=True, add_na=False):
    234         store_attr(self, self.store_attrs+',sort')

/usr/local/lib/python3.6/dist-packages/fastcore/utils.py in _f(*args, **kwargs)
    470         init_args.update(log)
    471         setattr(inst, 'init_args', init_args)
--> 472         return inst if to_return else f(*args, **kwargs)
    473     return _f
    474 

/usr/local/lib/python3.6/dist-packages/fastai2/layers.py in __init__(self, axis, *args, **kwargs)
    304     y_int = True
    305     @use_kwargs_dict(keep=True, weight=None, ignore_index=-100, reduction='mean')
--> 306     def __init__(self, *args, axis=-1, **kwargs): super().__init__(nn.CrossEntropyLoss, *args, axis=axis, **kwargs)
    307     def decodes(self, x):    return x.argmax(dim=self.axis)
    308     def activation(self, x): return F.softmax(x, dim=self.axis)

/usr/local/lib/python3.6/dist-packages/fastcore/utils.py in _f(*args, **kwargs)
    470         init_args.update(log)
    471         setattr(inst, 'init_args', init_args)
--> 472         return inst if to_return else f(*args, **kwargs)
    473     return _f
    474 

/usr/local/lib/python3.6/dist-packages/fastai2/layers.py in __init__(self, loss_cls, axis, flatten, floatify, is_2d, *args, **kwargs)
    279     activation=decodes=noops
    280     def __init__(self, loss_cls, *args, axis=-1, flatten=True, floatify=False, is_2d=True, **kwargs):
--> 281         store_attr(self, "axis,flatten,floatify,is_2d")
    282         self.func = loss_cls(*args,**kwargs)
    283         functools.update_wrapper(self, self.func)

/usr/local/lib/python3.6/dist-packages/fastcore/utils.py in store_attr(names, self, but, **attrs)
     95     args,varargs,keyw,locs = inspect.getargvalues(fr)
     96     if self is None: self = locs[args[0]]
---> 97     if not hasattr(self, '__stored_args__'): self.__stored_args__ = {}
     98     if attrs: return _store_attr(self, **attrs)
     99 

AttributeError: 'str' object has no attribute '__stored_args__'
oguiza commented 3 years ago

I've made a major update to the tsai library and it should work well now with fastai v2. Please, let me know if you still have any issues.