Keras 多元数据的GRU训练

Keras 多元数据的GRU训练,keras,lstm,tensorflow2.0,recurrent-neural-network,Keras,Lstm,Tensorflow2.0,Recurrent Neural Network,我正在尝试使用GRU训练多元数据。 数据输入/输出格式为 输入形状(1231,30,3) 输出形状(1231、7、3) 共有1231个数据集。 输入形状为30,3,输出形状为7,3,如下所示 输入数据 [[451. 163. 288.] [458. 166. 292.] [460. 168. 292.] [460. 168. 292.] [464. 169. 295.] [470. 172. 298.] [476. 174. 302.] [479. 176. 303.] [479

我正在尝试使用GRU训练多元数据。 数据输入/输出格式为 输入形状(1231,30,3) 输出形状(1231、7、3)

共有1231个数据集。 输入形状为30,3,输出形状为7,3,如下所示

输入数据

[[451. 163. 288.]
 [458. 166. 292.]
 [460. 168. 292.]
 [460. 168. 292.]
 [464. 169. 295.]
 [470. 172. 298.]
 [476. 174. 302.]
 [479. 176. 303.]
 [479. 176. 303.]
 [479. 176. 303.]
 [479. 176. 303.]
 [486. 179. 307.]
 [491. 183. 308.]
 [494. 183. 311.]
 [501. 187. 314.]
 [507. 191. 316.]
 [510. 193. 317.]
 [510. 193. 317.]
 [514. 195. 319.]
 [518. 196. 322.]
 [522. 196. 326.]
 [533. 201. 332.]
 [540. 204. 336.]
 [545. 205. 340.]
 [545. 205. 340.]
 [558. 209. 349.]
 [566. 214. 352.]
 [574. 218. 356.]
 [581. 221. 360.]
 [589. 224. 365.]]
输出数据

[[592. 294. 298.]
 [592. 294. 298.]
 [583. 290. 293.]
 [578. 289. 289.]
 [569. 285. 284.]
 [567. 284. 283.]
 [565. 283. 282.]]
我有如下GRU模型

n_steps = 30
predict_period=7
def create_GRU_model():
    model = Sequential()
    model.add(GRU(32, input_shape=(n_steps, n_features), activation='relu', return_sequences=True)) 
    model.add(Dropout(0.4)) 
    model.add(GRU(16, activation='relu'))
    model.add(Dropout(0.3)) 
    model.add(Dense(predict_period,n_features)) 
    
    optimizer = keras.optimizers.Adam(lr=0.0001)
    model.compile(optimizer, loss='mse') 
    return model
GRU_model = create_GRU_model()  
错误如下

TypeError                                 Traceback (most recent call last)
<ipython-input-8-6f82c6f91502> in <module>()
     20     model.compile(optimizer, loss='mse')
     21     return model
---> 22 GRU_model = create_GRU_model()
     23 #stack_lstm_model = load_model('stack_lstm_model')
     24 # fit model

3 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/activations.py in get(identifier)
    579     raise TypeError(
    580         'Could not interpret activation function identifier: {}'.format(
--> 581             identifier))

TypeError: Could not interpret activation function identifier: 3
TypeError回溯(最近一次调用)
在()
20模型。编译(优化器,loss='mse')
21返回模型
--->22 GRU_模型=创建GRU_模型()
23#堆栈模型=负载模型(“堆栈模型”)
24#适合模型
3帧
/get中的usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/activations.py(标识符)
579 raise TYPE错误(
580'无法解释激活函数标识符:{}。格式(
-->581(标识符)
TypeError:无法解释激活功能标识符:3

有什么问题吗?

[按顺序排列的参数是特性和激活函数。
predict\u period
,你想用它给出什么呢?那么我怎样才能得到7x3形状的输出呢?在所有GRU层中使用
return\u sequences
,只取最后三个输出。使用函数API而不是
Sequent可能会更好ial