Week 2
,ResNet
,assignment
,W2A1
- Link to the classroom item: Coursera | Online Courses & Credentials From Top Educators. Join for Free | Coursera
*Issue Description:
I’m currently working on the convolutional_block
function for the ResNet implementation in W2A1. My code passes the shape test, and even the inference mode output matches the expected tensor exactly. However, it fails the final assertion during training mode (training=True
).
This is the error message I get:
tf.Tensor(
[[[0. 2.4476275 1.8830043 0.21259236 1.922003 0. ]
[0. 2.1546977 1.6514317 0. 1.7889941 0. ]]
[[0. 1.8540058 1.3404746 0. 1.0688392 0. ]
[0. 1.6571904 1.1809819 0. 0.9483792 0. ]]], shape=(2, 2, 6), dtype=float32)
AssertionError Traceback (most recent call last)
Input In [147], in <cell line: 3>()
1 ### you cannot edit this cell
----> 3 public_tests.convolutional_block_test(convolutional_block)
File /tf/W2A1/public_tests.py:115, in convolutional_block_test(target)
112 tf.keras.backend.set_learning_phase(True)
114 C = target(X, f = 2, filters = [2, 4, 6])
→ 115 assert np.allclose(C.numpy(), convolutional_block_output2), “Wrong values when training=True.”
117 print(‘\033[92mAll tests passed!’)
AssertionError: Wrong values when training=True.
AssertionError: Wrong values when training=True.
Here’s the shape and tensor I’m getting in training mode:
tf.Tensor(
[[[0. 2.4476275 1.8830043 0.21259236 1.922003 0. ]
[0. 2.1546977 1.6514317 0. 1.7889941 0. ]]
[[0. 1.8540058 1.3404746 0. 1.0688392 0. ]
[0. 1.6571904 1.1809819 0. 0.9483792 0. ]]], shape=(2, 2, 6), dtype=float32)