In the alpaca model the error output is the following:
"AssertionError: The number of layers in the model is incorrect. Expected: 8 Found: 12"
I don’t know where the error might be, cause I didn’t add any layer.
In the alpaca model the error output is the following:
"AssertionError: The number of layers in the model is incorrect. Expected: 8 Found: 12"
I don’t know where the error might be, cause I didn’t add any layer.
Please share the full error…
Thank you for your help. It’s just an assertion error:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-73-0346cb4bf847> in <module>
10 ['Dense', (None, 1), 1281, 'linear']] #linear is the default activation
11
---> 12 comparator(summary(model2), alpaca_summary)
13
14 for layer in summary(model2):
~/work/W2A2/test_utils.py in comparator(learner, instructor)
14 def comparator(learner, instructor):
15 if len(learner) != len(instructor):
---> 16 raise AssertionError(f"The number of layers in the model is incorrect. Expected: {len(instructor)} Found: {len(learner)}")
17 for a, b in zip(learner, instructor):
18 if tuple(a) != tuple(b):
AssertionError: The number of layers in the model is incorrect. Expected: 8 Found: 12
You can print out summary(model2)
and alpaca_summary
and compare them. That should give you a clue as to the nature of your bug.
Ok, I see there are additional layers after the dropout. Here’s the summary of the model 2:
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_9 (InputLayer) [(None, 160, 160, 3) 0
__________________________________________________________________________________________________
sequential_1 (Sequential) (None, 160, 160, 3) 0 input_9[0][0]
__________________________________________________________________________________________________
tf_op_layer_RealDiv_6 (TensorFl [(None, 160, 160, 3) 0 sequential_1[3][0]
__________________________________________________________________________________________________
tf_op_layer_Sub_6 (TensorFlowOp [(None, 160, 160, 3) 0 tf_op_layer_RealDiv_6[0][0]
__________________________________________________________________________________________________
mobilenetv2_1.00_160 (Functiona (None, 5, 5, 1280) 2257984 tf_op_layer_Sub_6[0][0]
__________________________________________________________________________________________________
average_pooling2d_3 (AveragePoo (None, 2, 2, 1280) 0 mobilenetv2_1.00_160[0][0]
__________________________________________________________________________________________________
dropout_3 (Dropout) (None, 2, 2, 1280) 0 average_pooling2d_3[0][0]
__________________________________________________________________________________________________
tf_op_layer_Max_3 (TensorFlowOp [(None, 2, 2, 1)] 0 dropout_3[0][0]
__________________________________________________________________________________________________
tf_op_layer_Sub_7 (TensorFlowOp [(None, 2, 2, 1280)] 0 dropout_3[0][0]
tf_op_layer_Max_3[0][0]
__________________________________________________________________________________________________
tf_op_layer_Exp_3 (TensorFlowOp [(None, 2, 2, 1280)] 0 tf_op_layer_Sub_7[0][0]
__________________________________________________________________________________________________
tf_op_layer_Sum_3 (TensorFlowOp [(None, 2, 2, 1)] 0 tf_op_layer_Exp_3[0][0]
__________________________________________________________________________________________________
tf_op_layer_RealDiv_7 (TensorFl [(None, 2, 2, 1280)] 0 tf_op_layer_Exp_3[0][0]
tf_op_layer_Sum_3[0][0]
==================================================================================================
I see that in the alpaca_summary there’s only one layer after the dropout_3, and I actually see the sense in it:
[['InputLayer', [(None, 160, 160, 3)], 0], ['Sequential', (None, 160, 160, 3), 0],
['TensorFlowOpLayer', [(None, 160, 160, 3)], 0], ['TensorFlowOpLayer', [(None, 160, 160, 3)], 0],
['Functional', (None, 5, 5, 1280), 2257984], ['GlobalAveragePooling2D', (None, 1280), 0],
['Dropout', (None, 1280), 0, 0.2], ['Dense', (None, 1), 1281, 'linear']]
I don’t know where that extra layers came from.
Ok, I figured out what the output should be, but I don’t understand why the activation is linear and not softmax. Thank you for your help!
Because we use from_logits=True
. Check out this MLS video (open it in incognito mode without login if needed) for more explanation.
Cheers,
Raymond