Keras中使用ClockworkRNN模型(cwrnn)

模型github地址:python

https://github.com/liangzulin/cwrnn_for_keras_2_1_abovegit

模型的训练和预测结果:github

模型从epochs=0一直到99次迭代后的训练准确率和预测准确率曲线:debug

模型的简单使用方法:code

model = Sequential()
model.add(ClockworkRNN(units=90,
                       period_spec=[1, 2, 4, 8, 16],
                       input_shape=train_x.shape[1:],  # ---(samples, timesteps, dimension)
                       dropout_W=0.4,
                       return_sequences=True,
                       debug=cwrnn_debug))  # debug is for developing mode, you can remove
model.add(Dropout(.2))
model.add(TimeDistributed(Dense(units=1, activation='linear')))
model.compile(loss='mse', optimizer='sgd', metrics=['accuracy'])

model.fit(train_x, train_y, epochs=epochs, batch_size=1, verbose=1)

 

不一样版本keras调用可能会出现报错,须要注意调用区别:rem

一、get

 

二、出现Exception: Error when checking : expected dense_input_1 to have shape (None, 784) but got array with shape (784, 1)相似的错误,说明输入数据的维度与模型需求不符合,须要更改维度(参考:by https://stackoverflow.com/questions/39950311/keras-error-on-predict/40489174https://github.com/keras-team/keras/issues/3109input

相关文章
相关标签/搜索