模型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/40489174、https://github.com/keras-team/keras/issues/3109)input