From 3015aab6fda3d3833c4a64e7a5dd37843f11845d Mon Sep 17 00:00:00 2001 From: "Ashwin V. Mohanan" <9155111+ashwinvis@users.noreply.github.com> Date: Tue, 14 Jan 2025 17:03:17 +0100 Subject: [PATCH] Updated model.summary() for ep. 3 (#538) --- episodes/3-monitor-the-model.Rmd | 103 ++++++++++++++++++------------- 1 file changed, 59 insertions(+), 44 deletions(-) diff --git a/episodes/3-monitor-the-model.Rmd b/episodes/3-monitor-the-model.Rmd index 2c5c1e2c..76232724 100644 --- a/episodes/3-monitor-the-model.Rmd +++ b/episodes/3-monitor-the-model.Rmd @@ -228,20 +228,24 @@ model.summary() ``` ```output Model: "weather_prediction_model" -_________________________________________________________________ -Layer (type) Output Shape Param # -================================================================= -input (InputLayer) [(None, 89)] 0 -_________________________________________________________________ -dense (Dense) (None, 100) 9000 -_________________________________________________________________ -dense_1 (Dense) (None, 50) 5050 -_________________________________________________________________ -dense_2 (Dense) (None, 1) 51 -================================================================= -Total params: 14,101 -Trainable params: 14,101 -Non-trainable params: 0 + +┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓ +┃ Layer (type) ┃ Output Shape ┃ Param # ┃ +┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩ +│ input (InputLayer) │ (None, 89) │ 0 │ +├─────────────────────────────┼─────────────────────┼───────────────┤ +│ dense (Dense) │ (None, 100) │ 9,000 │ +├─────────────────────────────┼─────────────────────┼───────────────┤ +│ dense_1 (Dense) │ (None, 50) │ 5,050 │ +├─────────────────────────────┼─────────────────────┼───────────────┤ +│ dense_2 (Dense) │ (None, 1) │ 51 │ +└─────────────────────────────┴─────────────────────┴───────────────┘ + + Total params: 14,101 (55.08 KB) + + Trainable params: 14,101 (55.08 KB) + + Non-trainable params: 0 (0.00 B) ``` @@ -640,20 +644,26 @@ model.summary() ``` ``` Model: "model_small" -_________________________________________________________________ -Layer (type) Output Shape Param # -================================================================= -input (InputLayer) [(None, 89)] 0 -_________________________________________________________________ -dense_9 (Dense) (None, 10) 900 -_________________________________________________________________ -dense_10 (Dense) (None, 5) 55 -_________________________________________________________________ -dense_11 (Dense) (None, 1) 6 -================================================================= -Total params: 961 -Trainable params: 961 -Non-trainable params: 0 + +┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓ +┃ Layer (type) ┃ Output Shape ┃ Param # ┃ +┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩ +│ input (InputLayer) │ (None, 89) │ 0 │ +├─────────────────────────────┼─────────────────────┼───────────────┤ +│ dense_9 (Dense) │ (None, 10) │ 900 │ +├─────────────────────────────┼─────────────────────┼───────────────┤ +│ dense_10 (Dense) │ (None, 5) │ 55 │ +├─────────────────────────────┼─────────────────────┼───────────────┤ +│ dense_11 (Dense) │ (None, 1) │ 6 │ +└─────────────────────────────┴─────────────────────┴───────────────┘ + + Total params: 961 (3.75 KB) + + Trainable params: 961 (3.75 KB) + + Non-trainable params: 0 (0.00 B) + + ``` Let's compile and train this network: @@ -762,22 +772,27 @@ This new layer appears in the model summary as well. ```output Model: "model_batchnorm" -_________________________________________________________________ -Layer (type) Output Shape Param # -================================================================= -input_1 (InputLayer) [(None, 89)] 0 -_________________________________________________________________ -batch_normalization (BatchNo (None, 89) 356 -_________________________________________________________________ -dense (Dense) (None, 100) 9000 -_________________________________________________________________ -dense_1 (Dense) (None, 50) 5050 -_________________________________________________________________ -dense_2 (Dense) (None, 1) 51 -================================================================= -Total params: 14,457 -Trainable params: 14,279 -Non-trainable params: 178 + +┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓ +┃ Layer (type) ┃ Output Shape ┃ Param # ┃ +┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩ +│ input (InputLayer) │ (None, 89) │ 0 │ +├─────────────────────────────┼─────────────────────┼───────────────┤ +│ batch_normalization_1 │ (None, 89) │ 356 │ +│ (BatchNormalization) │ │ │ +├─────────────────────────────┼─────────────────────┼───────────────┤ +│ dense_6 (Dense) │ (None, 100) │ 9,000 │ +├─────────────────────────────┼─────────────────────┼───────────────┤ +│ dense_7 (Dense) │ (None, 50) │ 5,050 │ +├─────────────────────────────┼─────────────────────┼───────────────┤ +│ dense_8 (Dense) │ (None, 1) │ 51 │ +└─────────────────────────────┴─────────────────────┴───────────────┘ + + Total params: 14,457 (56.47 KB) + + Trainable params: 14,279 (55.78 KB) + + Non-trainable params: 178 (712.00 B) ``` We can train the model again as follows: