C2_W1_Assignment - No error in Coursera but errors in Jupyter lab

Coursera Machine Learning Specialization

C2 W1 Assignment - When I run the code in the online lab, it runs without error but when I run the same code in jupyter lab outside of the coursera class the code produces an error message. Can someone tell me why I get this error : --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[44], line 4 1 # UNIT TESTS 2 from public_tests import * ----> 4 test_c1(model) in test_c1(target) 7 def test_c1(target): 8 assert len(target.layers) == 3, \ 9 f"Wrong number of layers. Expected 3 but got {len(target.layers)}" —> 10 assert target.input.shape.as_list() == [None, 400], \ 11 f"Wrong input shape. Expected [None, 400] but got {target.input.shape.as_list()}" 12 i = 0 13 expected = [[Dense, [None, 25], tf_keras_sigmoid], 14 [Dense, [None, 15], tf_keras_sigmoid], 15 [Dense, [None, 1], tf_keras_sigmoid]] File , in Operation.input(self) 244 @property 245 def input(self): 246 “”“Retrieves the input tensor(s) of a symbolic operation. 247 248 Only returns the tensor(s) corresponding to the first time (…) 252 Input tensor or list of input tensors. 253 “”” → 254 return self._get_node_attribute_at_index(0, “input_tensors”, “input”) , in Operation._get_node_attribute_at_index(self, node_index, attr, attr_name) 269 “”“Private utility to retrieves an attribute (e.g. inputs) from a node. 270 271 This is used to implement the properties: (…) 282 The operation’s attribute attr at the node of index node_index. 283 “”” 284 if not self._inbound_nodes: → 285 raise AttributeError( 286 f"The layer {self.name} has never been called " 287 f"and thus has no defined {attr_name}." 288 ) 289 if not len(self._inbound_nodes) > node_index: 290 raise ValueError( 291 f"Asked to get {attr_name} at node " 292 f"{node_index}, but the operation has only " 293 f"{len(self._inbound_nodes)} inbound nodes." 294 ) AttributeError: The layer my_model has never been called and thus has no defined input.

What you can do as starter is check all the additional files that are in the lab folder in Coursera and then try to incorporate them in your workspace as well.

I would guess that your local installation does not use exactly the same versions of all of the packages that Coursera provides.