Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced Learning Algorithms - C2_W1_Assignment issue #1

Open
johnfelipe opened this issue Jun 19, 2022 · 10 comments
Open

Advanced Learning Algorithms - C2_W1_Assignment issue #1

johnfelipe opened this issue Jun 19, 2022 · 10 comments

Comments

@johnfelipe
Copy link

# UNIT TESTS
from public_tests import * 

test_c1(model)

with this log

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-9-c43f6ee12586> in <module>
      2 from public_tests import *
      3 
----> 4 test_c1(model)

~/work/public_tests.py 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()}"

AssertionError: Wrong number of layers. Expected 3 but got 0
@johnfelipe johnfelipe changed the title C2_W1_Assignment issue Advanced Learning Algorithms - C2_W1_Assignment issue Jun 19, 2022
@kaieye
Copy link
Owner

kaieye commented Jun 19, 2022

Sorry that I am not familiar with Tensorflow. I think that you can click the Hint below the cell first, which helps a lot.
If you agree, give me your code of function can help me get deeper insight into your problem

@johnfelipe
Copy link
Author

Advanced Learning Algorithms/week1/9.Practice Lab Neural networks/C2_W1_Assignment.ipynb

SNAG-1306

is stop in step 9, how solve?

@kaieye
Copy link
Owner

kaieye commented Jun 20, 2022

fill the code in the function of model

@johnfelipe
Copy link
Author

can u upload file with all complete?

@kaieye
Copy link
Owner

kaieye commented Jun 20, 2022

I haven't done yet, but I think you can find the answer in the "Click for hints"

@johnfelipe
Copy link
Author

i will wait, pls ping me when you done

@kaieye
Copy link
Owner

kaieye commented Jun 20, 2022

deal, within seven days

@kaieye
Copy link
Owner

kaieye commented Jun 24, 2022

image
image
image
check

@usernameuiui
Copy link

image

@KasrAskari
Copy link

I wrote the code for this model, and I also have confirmation of the output correctness for the summary, but in the section:

# UNQ_C1
# GRADED CELL: Sequential model

model = Sequential(
    [               
        tf.keras.Input(shape=(400,)),    #specify input size
        ### START CODE HERE ### 
        
        tf.keras.layers.Dense(25, activation='sigmoid'),
        tf.keras.layers.Dense(15, activation='sigmoid'),
        tf.keras.layers.Dense(1, activation='sigmoid')
        
        ### END CODE HERE ### 
    ], name = "my_model" 
)                            
# UNIT TESTS
from public_tests import *
test_c1(model)

I'm getting this error:

AttributeError                            Traceback (most recent call last)
Cell In[13], line 4
      1 # UNIT TESTS
      2 from public_tests import *
----> 4 test_c1(model)

File c:\Users\Asus\ML\Home\Helper\Machine Learning\Coursera\2- Advanced\Week 1\Practice-Lab\public_tests.py:10, 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 c:\Users\Asus\ML\mymlvenv\Lib\site-packages\keras\src\ops\operation.py:254, 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")

File c:\Users\Asus\ML\mymlvenv\Lib\site-packages\keras\src\ops\operation.py:285, 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.
``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants