From 555cacad999fb24f52803f28eb221ac04b7607d7 Mon Sep 17 00:00:00 2001 From: Jan Date: Sat, 18 Feb 2023 22:16:55 -0700 Subject: [PATCH] in fmda_kf_rnn_orig call moisture_rnn.create_RNN_2 -> moisture_rnn.create_RNN_2 print x_train y_train shape in fmda_kf_rnn_orig and fmda_rnn_raine verbose=1 in model.fit still different, same as before --- fmda/fmda_kf_rnn_orig.ipynb | 27 +++++++++++++++++++++------ fmda/fmda_rnn_rain.ipynb | 18 ++++++++++++++++-- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/fmda/fmda_kf_rnn_orig.ipynb b/fmda/fmda_kf_rnn_orig.ipynb index dfc29eb..316825e 100644 --- a/fmda/fmda_kf_rnn_orig.ipynb +++ b/fmda/fmda_kf_rnn_orig.ipynb @@ -1500,7 +1500,9 @@ "h0 = tf.convert_to_tensor(datat[:samples],dtype=tf.float32)\n", "# print('initial state=',h0)\n", "# statefull model version for traning\n", - "model_fit=create_RNN_2(hidden_units=hidden_units, \n", + "import moisture_rnn\n", + "# model_fit=create_RNN_2(hidden_units=hidden_units, \n", + "model_fit=moisture_rnn.create_RNN_2(hidden_units=hidden_units, \n", " dense_units=dense_units, \n", " batch_shape=(samples,timesteps,features),\n", " stateful=True,\n", @@ -2694,7 +2696,8 @@ "h0 = tf.convert_to_tensor(datat[:samples],dtype=tf.float32)\n", "# print('initial state=',h0)\n", "# statefull model version for traning\n", - "model_fit=create_RNN_2(hidden_units=hidden_units, \n", + "import moisture_rnn\n", + "model_fit=moisture_rnn.create_RNN_2(hidden_units=hidden_units, \n", " dense_units=dense_units, \n", " batch_shape=(samples,timesteps,features),\n", " stateful=True,\n", @@ -2957,7 +2960,8 @@ "h0 = tf.convert_to_tensor(datat[:samples],dtype=tf.float32)\n", "# print('initial state=',h0)\n", "# statefull model version for traning\n", - "model_fit=create_RNN_2(hidden_units=hidden_units, \n", + "import moisture_rnn\n", + "model_fit=moisture_rnn.create_RNN_2(hidden_units=hidden_units, \n", " dense_units=dense_units, \n", " batch_shape=(samples,timesteps,features),\n", " stateful=True,\n", @@ -2968,7 +2972,7 @@ "# same model stateless for prediction on the entire dataset - to start onlg\n", "# the real application will switch to prediction after training data end\n", "# and start from the state there\n", - "print('model_fit input shape',x_train.shape,'output shape',model_fit(x_train).shape)\n", + "print('model_fit input shape',x_train.shape,'output shape',model_fit(y_train).shape)\n", "from keras.utils.vis_utils import plot_model\n", "plot_model(model_fit, to_file='model_plot.png', \n", " show_shapes=True, show_layer_names=True)" @@ -3006,7 +3010,7 @@ }, "outputs": [], "source": [ - "model_predict=create_RNN_2(hidden_units=hidden_units, dense_units=dense_units, \n", + "model_predict=moisture_rnn.create_RNN_2(hidden_units=hidden_units, dense_units=dense_units, \n", " input_shape=(hours,features),stateful = False,\n", " return_sequences=True,\n", " activation=activation,dense_layers=dense_layers)\n", @@ -3074,6 +3078,17 @@ "metadata": {}, "outputs": [], "source": [ + "print('model_fit input shape',x_train.shape,'output shape',y_train.shape)\n", + "print('x_train',x_train)\n", + "print('y_train',y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "reproducibility.set_seed()" ] }, @@ -3092,7 +3107,7 @@ "metadata": {}, "outputs": [], "source": [ - "model_fit.fit(x_train, y_train, epochs=5000, verbose=0,batch_size=samples)\n", + "model_fit.fit(x_train, y_train, epochs=5000, verbose=1,batch_size=samples)\n", "w_fitted=model_fit.get_weights()\n", "for i in range(len(w)):\n", " print('weight',i,' exact:',w_exact[i],': initial:',w_initial[i],' fitted:',w_fitted[i])" diff --git a/fmda/fmda_rnn_rain.ipynb b/fmda/fmda_rnn_rain.ipynb index ca321d2..43628c0 100644 --- a/fmda/fmda_rnn_rain.ipynb +++ b/fmda/fmda_rnn_rain.ipynb @@ -487,8 +487,10 @@ "metadata": {}, "outputs": [], "source": [ + "print(rnn_dat)\n", "x_train = rnn_dat['x_train']\n", "y_train = rnn_dat['y_train']\n", + "type(x_train)\n", "\n", "# fitting\n", "DeltaE = 0\n", @@ -524,6 +526,18 @@ { "cell_type": "code", "execution_count": null, + "id": "33d6b35c", + "metadata": {}, + "outputs": [], + "source": [ + "print('model_fit input shape',x_train.shape,'output shape',y_train.shape)\n", + "print('x_train',x_train)\n", + "print('y_train',y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": null, "id": "7a2be797", "metadata": {}, "outputs": [], @@ -534,7 +548,7 @@ { "cell_type": "code", "execution_count": null, - "id": "adc56d77", + "id": "c7857fb4", "metadata": {}, "outputs": [], "source": [ @@ -548,7 +562,7 @@ "metadata": {}, "outputs": [], "source": [ - "model_fit.fit(x_train, y_train, epochs=5000, verbose=0, batch_size=samples)\n", + "model_fit.fit(x_train, y_train, epochs=5000, verbose=1, batch_size=samples)\n", "w_fitted=model_fit.get_weights()\n", "for i in range(len(w)):\n", " vprint('weight',i,' exact:',w_exact[i],': initial:',w_initial[i],' fitted:',w_fitted[i])\n", -- 2.11.4.GIT