1717
1818def create_model (input_shape = (384 ,384 ,13 ),
1919 start_neurons = 32 ,
20- num_outputs = 12 ,
21- activation = 'relu' ):
20+ num_outputs = 12 ,
21+ activation = 'relu' ):
2222 """
2323
2424 Inputs are assumed to be in range [0-255].
@@ -27,18 +27,12 @@ def create_model(input_shape=(384,384,13),
2727
2828 """
2929 inputs = layers .Input (shape = input_shape )
30-
31- # normalize inputs
32- ir069 = tf .keras .layers .Input (shape = (192 ,192 ,1 ))
33- ir107 = tf .keras .layers .Input (shape = (192 ,192 ,1 ))
34- lght = tf .keras .layers .Input (shape = (48 ,48 ,1 ))
35- inputs = [ir069 ,ir107 ,lght ]
3630
3731 # Normalize inputs
38- ir069_norm = tf .keras .layers .Lambda (lambda x ,mu ,scale : (x - mu )/ scale ,
39- arguments = {'mu' :MEAN ,'scale' :SCALE })(inputs )
32+ inputs_norm = tf .keras .layers .Lambda (lambda x ,mu ,scale : (x - mu )/ scale ,
33+ arguments = {'mu' :MEAN ,'scale' :SCALE })(inputs )
4034
41- encoder0_pool , encoder0 = encoder_block (inputs , start_neurons , activation = activation )
35+ encoder0_pool , encoder0 = encoder_block (inputs_norm , start_neurons , activation = activation )
4236 encoder1_pool , encoder1 = encoder_block (encoder0_pool , start_neurons * 2 , activation = activation )
4337 encoder2_pool , encoder2 = encoder_block (encoder1_pool , start_neurons * 4 , activation = activation )
4438 encoder3_pool , encoder3 = encoder_block (encoder2_pool , start_neurons * 8 , activation = activation )
@@ -50,21 +44,21 @@ def create_model(input_shape=(384,384,13),
5044 outputs = layers .Conv2D (num_outputs , (1 , 1 ), padding = 'same' ,
5145 activation = 'linear' , name = 'output_layer' )(decoder0 )
5246
53- return inputs , outputs
47+ return tf . keras . models . Model ( inputs = inputs , outputs = outputs , name = 'nowcast_model' )
5448
5549
5650def nowcast_mse (y_true ,y_pred ):
57- """
58- MSE loss normalized by SCALE*SCALE
59- """
60- return mean_squared_error (y_true ,y_pred )/ (SCALE * SCALE )
51+ """
52+ MSE loss normalized by SCALE*SCALE
53+ """
54+ return mean_squared_error (y_true ,y_pred )/ (SCALE * SCALE )
6155
6256
6357def nowcast_mae (y_true ,y_pred ):
64- """
65- MAE normalized by SCALE
66- """
67- retrun mean_absolute_error (y_true ,y_pred )/ (SCALE )
58+ """
59+ MAE normalized by SCALE
60+ """
61+ return mean_absolute_error (y_true ,y_pred )/ (SCALE )
6862
6963
7064
0 commit comments