data--the original array of floating-point datawhich you normalized in listing lookback--how many timesteps back the input data should go delay--how many timesteps in the future the target should be min_index and max_index--indices in the data array that delimit which timesteps to draw from this is useful for keeping segment of the data for validation and another for testing shuffle--whether to shuffle the samples or draw them in chronological order batch_size--the number of samples per batch step--the periodin timestepsat which you sample data you'll set it to in order to draw one data point every hour listing generat or yielding imeseries samples and heir arget def generator(datalookbackdelaymin_indexmax_indexshuffle=falsebatch_size= step= )if max_index is nonemax_index len(datadelay min_index lookback while if shufflerows np random randintmin_index lookbackmax_indexsize=batch_sizeelseif batch_size >max_indexi min_index lookback rows np arange(imin( batch_sizemax_index) +len(rowssamples np zeros((len(rows)lookback /stepdata shape[- ])targets np zeros((len(rows),)for jrow in enumerate(rows)indices range(rows[jlookbackrows[ ]stepsamples[jdata[indicestargets[jdata[rows[jdelay][ yield samplestargets nowlet' use the abstract generator function to instantiate three generatorsone for trainingone for validationand one for testing each will look at different temporal segments of the original datathe training generator looks at the first , timestepsthe validation generator looks at the following , and the test generator looks at the remainder listing preparing he rainingvalidat ionand est generat ors lookback step delay batch_size licensed to