Home > database >  cannot import name 'TimeSeriesGenerator' from 'keras.preprocessing.sequence'
cannot import name 'TimeSeriesGenerator' from 'keras.preprocessing.sequence'

Time:06-02

I'm new to keras and trying to work with this, however, I have problem in the imports.

I can import all the following packages:

import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler
from tensorflow.keras.models import Model
from tensorflow.keras.optimizers import Nadam
from tensorflow.keras.layers import Input, LSTM, Dense
from tensorflow.keras.callbacks import EarlyStopping, ReduceLROnPlateau, TerminateOnNaN
from tensorflow.keras.preprocessing.sequence import TimeseriesGenerator

but when I try to import the time series generatore I get an error:

from keras.preprocessing.sequence import TimeSeriesGenerator

>>>mportError: cannot import name 'TimeSeriesGenerator' from 'keras.preprocessing.sequence' (C:\path\myuser\anaconda3\envs\keras1\lib\site-packages\keras\preprocessing\sequence.py)

This happens after I have created new environment, installed first tensorflow, but nothing changes and I keep getting this error.

What am I missing? how can I solve it and use the timeseries generator?

CodePudding user response:

You misspelled the import, it should be TimeseriesGenerator (lowercase s)

  • Related