title: Usage TimeseriesGenerator with Datasets
body: <p>i try to feed my Keras model with timeseries. I load my training data with experimental.make_csv_dataset. How can i generate timeseries from my dataset? Thank you</p>
  <pre><code>import tensorflow as tf
  from tensorflow.keras.layers import *
  from tensorflow.keras.models import Model
  from tensorflow.keras.preprocessing.sequence import TimeseriesGenerator
  
  dataset = tf.data.experimental.make_csv_dataset(
  &quot;Mydata/*.csv&quot;,
  batch_size=128,
  field_delim=&quot;,&quot;,
  num_epochs=1,
  select_columns=['X1', 'X2', 'X3', 'Y'],
  label_name='Y',
  shuffle=False)
  
  mydataset_x = dataset.map(lambda x, y: (tf.concat(
  [tf.expand_dims(x['X1'], axis=-1), tf.expand_dims(x['X2'], axis=-1), tf.expand_dims(x['X3'], axis=-1)], axis=-1), y)) 
  
  train_generator = TimeseriesGenerator(mydataset_x , length=10, sampling_rate=1, batch_size=128)
  
  inputs = Input(shape=(10, 3,))  # input tensor   
  hidden1 = LSTM(8)(inputs)
  outputs = Dense(units=1, activation='linear')(hidden1)  # hidden layer 1
  
  model_lstm = Model(inputs, outputs)
  model_lstm.compile(loss='mean_absolute_error', optimizer=&quot;adam&quot;, metrics=['mean_squared_error'])    
  
  history = model_lstm.fit(train_generator, epochs=1)
  </code></pre>