问题描述
我正在构建LSTM ANN,但不确定在我的情况下使用生成器。网络应具有应迭代的几个超参数,例如时期,激活函数...,但是,如果在这种情况下使用生成器,则每次迭代都在不同的集合上进行训练,对吗?那么更正确的方法是使用列表或数组?谢谢
for epoch in EPOCHS do:
for activation in ACTIVATION do:
trainLSTM(epoch,activation)
save best model
解决方法
建议将Generator
的{{1}}用于Tutorial of Tensorflow Time Series Analysis。这样的Time Series Data
的代码如下所示:
Generator
例如,如果您的class WindowGenerator():
def __init__(self,input_width,label_width,shift,train_df=train_df,val_df=val_df,test_df=test_df,label_columns=None):
# Store the raw data.
self.train_df = train_df
self.val_df = val_df
self.test_df = test_df
# Work out the label column indices.
self.label_columns = label_columns
if label_columns is not None:
self.label_columns_indices = {name: i for i,name in
enumerate(label_columns)}
self.column_indices = {name: i for i,name in
enumerate(train_df.columns)}
# Work out the window parameters.
self.input_width = input_width
self.label_width = label_width
self.shift = shift
self.total_window_size = input_width + shift
self.input_slice = slice(0,input_width)
self.input_indices = np.arange(self.total_window_size)[self.input_slice]
self.label_start = self.total_window_size - self.label_width
self.labels_slice = slice(self.label_start,None)
self.label_indices = np.arange(self.total_window_size)[self.labels_slice]
def __repr__(self):
return '\n'.join([
f'Total window size: {self.total_window_size}',f'Input indices: {self.input_indices}',f'Label indices: {self.label_indices}',f'Label column name(s): {self.label_columns}'])
是从1960年(1月1日)到2016年(12月31日)的年份,并且您想Data
将2017年整个2月的天气,通过考虑过去2年的数据窗口,以下类的参数值如下所示:
predict