Can anyone help me understand where am I doing wrong? I can’t find the issue.
I am getting below error while running the below code
happy_model = happyModel()
Print a summary for each layer
for layer in summary(happy_model):
print(layer)
output = [[‘ZeroPadding2D’, (None, 70, 70, 3), 0, ((3, 3), (3, 3))],
[‘Conv2D’, (None, 64, 64, 32), 4736, ‘valid’, ‘linear’, ‘GlorotUniform’],
[‘BatchNormalization’, (None, 64, 64, 32), 128],
[‘ReLU’, (None, 64, 64, 32), 0],
[‘MaxPooling2D’, (None, 32, 32, 32), 0, (2, 2), (2, 2), ‘valid’],
[‘Flatten’, (None, 32768), 0],
[‘Dense’, (None, 1), 32769, ‘sigmoid’]]
comparator(summary(happy_model), output)
TypeError Traceback (most recent call last)
in
----> 1 happy_model = happyModel()
2 # Print a summary for each layer
3 for layer in summary(happy_model):
4 print(layer)
5
in happyModel()
41 tfl.MaxPool2D(pool_size=(2, 2)),
42 tfl.Flatten(),
—> 43 tfl.Dense(1, activation = ‘sigmoid’)
44
45
/opt/conda/lib/python3.7/site-packages/tensorflow/python/training/tracking/base.py in _method_wrapper(self, *args, **kwargs)
455 self._self_setattr_tracking = False # pylint: disable=protected-access
456 try:
→ 457 result = method(self, *args, **kwargs)
458 finally:
459 self._self_setattr_tracking = previous_value # pylint: disable=protected-access
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/sequential.py in init(self, layers, name)
140 layers = [layers]
141 for layer in layers:
→ 142 self.add(layer)
143
144 @property
/opt/conda/lib/python3.7/site-packages/tensorflow/python/training/tracking/base.py in _method_wrapper(self, *args, **kwargs)
455 self._self_setattr_tracking = False # pylint: disable=protected-access
456 try:
→ 457 result = method(self, *args, **kwargs)
458 finally:
459 self._self_setattr_tracking = previous_value # pylint: disable=protected-access
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/sequential.py in add(self, layer)
180 raise TypeError('The added layer must be ’
181 'an instance of class Layer. ’
→ 182 'Found: ’ + str(layer))
183
184 tf_utils.assert_no_legacy_layers([layer])
TypeError: The added layer must be an instance of class Layer. Found: Tensor(“zero_padding2d_63/Pad:0”, shape=(None, 70, 70, 3), dtype=float32)
Below is my happymodel function
GRADED FUNCTION: happyModel
Mentor edit: removed all but the incorrect line of code:
tfl.ZeroPadding2D(padding=3)(tf.keras.Input(shape = (64, 64, 3))),