Skip to content

[BUG] KeyError while training TFT pipeline #1078

Closed
1 task done
benzom opened this issue Jan 20, 2023 · 1 comment 路 Fixed by #1084
Closed
1 task done

[BUG] KeyError while training TFT pipeline #1078

benzom opened this issue Jan 20, 2023 · 1 comment 路 Fixed by #1084
Assignees
Labels
bug Something isn't working

Comments

@benzom
Copy link

benzom commented Jan 20, 2023

馃悰 Bug Report

Hi! I took code from your example of training tft model in documentation, but instead of using backtest chose to fit model explicitly on train part. I got KeyError: 'kwargs' after reaching maximum number of epochs. Backtesting works fine on this pipeline. (I'm using the whole dataset for it.)

Expected behavior

Fit method returns fitted model

How To Reproduce

I reproduced the same error in google colab (link here) with toy data from generate_ar_df, in my own example I used real data and had got the same error

Traceback

KeyError                                  Traceback (most recent call last)
[/usr/local/lib/python3.8/dist-packages/IPython/core/formatters.py](https://4x5aoca1vrd-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230118-060048-RC00_502821613#) in __call__(self, obj)
    700                 type_pprinters=self.type_printers,
    701                 deferred_pprinters=self.deferred_printers)
--> 702             printer.pretty(obj)
    703             printer.flush()
    704             return stream.getvalue()

3 frames
[/usr/local/lib/python3.8/dist-packages/IPython/lib/pretty.py](https://4x5aoca1vrd-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230118-060048-RC00_502821613#) in pretty(self, obj)
    400                         if cls is not object \
    401                                 and callable(cls.__dict__.get('__repr__')):
--> 402                             return _repr_pprint(obj, self, cycle)
    403 
    404             return _default_pprint(obj, self, cycle)

[/usr/local/lib/python3.8/dist-packages/IPython/lib/pretty.py](https://4x5aoca1vrd-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230118-060048-RC00_502821613#) in _repr_pprint(obj, p, cycle)
    695     """A pprint that just redirects to the normal repr function."""
    696     # Find newlines and replace them with p.break_()
--> 697     output = repr(obj)
    698     for idx,output_line in enumerate(output.splitlines()):
    699         if idx:

[/usr/local/lib/python3.8/dist-packages/etna/core/mixins.py](https://4x5aoca1vrd-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230118-060048-RC00_502821613#) in __repr__(self)
     30                     value = None
     31                     warnings.warn(f"You haven't set all parameters inside class __init__ method: {e}")
---> 32                 args_str_representation += f"{arg} = {repr(value)}, "
     33         return f"{self.__class__.__name__}({args_str_representation})"
     34 

[/usr/local/lib/python3.8/dist-packages/etna/core/mixins.py](https://4x5aoca1vrd-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230118-060048-RC00_502821613#) in __repr__(self)
     22                 continue
     23             elif param.kind == param.VAR_KEYWORD:
---> 24                 for arg_, value in self.__dict__[arg].items():
     25                     args_str_representation += f"{arg_} = {repr(value)}, "
     26             else:

KeyError: 'kwargs'KeyError                                  Traceback (most recent call last)
[/usr/local/lib/python3.8/dist-packages/IPython/core/formatters.py](https://4x5aoca1vrd-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230118-060048-RC00_502821613#) in __call__(self, obj)
    700                 type_pprinters=self.type_printers,
    701                 deferred_pprinters=self.deferred_printers)
--> 702             printer.pretty(obj)
    703             printer.flush()
    704             return stream.getvalue()

3 frames
[/usr/local/lib/python3.8/dist-packages/IPython/lib/pretty.py](https://4x5aoca1vrd-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230118-060048-RC00_502821613#) in pretty(self, obj)
    400                         if cls is not object \
    401                                 and callable(cls.__dict__.get('__repr__')):
--> 402                             return _repr_pprint(obj, self, cycle)
    403 
    404             return _default_pprint(obj, self, cycle)

[/usr/local/lib/python3.8/dist-packages/IPython/lib/pretty.py](https://4x5aoca1vrd-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230118-060048-RC00_502821613#) in _repr_pprint(obj, p, cycle)
    695     """A pprint that just redirects to the normal repr function."""
    696     # Find newlines and replace them with p.break_()
--> 697     output = repr(obj)
    698     for idx,output_line in enumerate(output.splitlines()):
    699         if idx:

[/usr/local/lib/python3.8/dist-packages/etna/core/mixins.py](https://4x5aoca1vrd-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230118-060048-RC00_502821613#) in __repr__(self)
     30                     value = None
     31                     warnings.warn(f"You haven't set all parameters inside class __init__ method: {e}")
---> 32                 args_str_representation += f"{arg} = {repr(value)}, "
     33         return f"{self.__class__.__name__}({args_str_representation})"
     34 

[/usr/local/lib/python3.8/dist-packages/etna/core/mixins.py](https://4x5aoca1vrd-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230118-060048-RC00_502821613#) in __repr__(self)
     22                 continue
     23             elif param.kind == param.VAR_KEYWORD:
---> 24                 for arg_, value in self.__dict__[arg].items():
     25                     args_str_representation += f"{arg_} = {repr(value)}, "
     26             else:

KeyError: 'kwargs'

Environment

No response

Additional context

No response

Checklist

  • Bug appears at the latest library version
@benzom benzom added the bug Something isn't working label Jan 20, 2023
@martins0n
Copy link
Contributor

martins0n commented Jan 27, 2023

Thank you for your report!

As a workaround I can suggest change pipeline_tft.fit(train_ts) to _ = pipeline_tft.fit(train_ts)

The issue is due to the first variant calls __repr__ in ipython enviroments - it seems we have some problems with __repr__ implementation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants