[Python] working on the two_layer_model function in the Week 4 Assignment (W4A2) of the Deep...

Discussão em 'Python' iniciado por Stack, Julho 11, 2025.

  1. Stack

    Stack Membro Participativo

    I’m working on the two_layer_model function in the Week 4 Assignment (W4A2) of the Deep Learning Specialization on Coursera.

    I’ve implemented the model using the required structure: LINEAR -> RELU -> LINEAR -> SIGMOID, and it returns both parameters and costs as expected.

    However, when I run the autograder with:

    parameters, costs = two_layer_model(train_x,
    train_y,
    layers_dims=(n_x, n_h, n_y),
    num_iterations=2)
    print("Cost after first iteration:", costs[0])
    two_layer_model_test(two_layer_model)


    I get the following error:

    Cost after first iteration: 0.6931955461346408
    Error: Datatype mismatch.
    Error: Wrong shape
    Error: Wrong output
    Error: Wrong output
    0 Tests passed
    4 Tests failed


    I’ve double-checked that I’m not using global variables, the function signature matches the expected one, and that parameters is a dictionary with keys 'W1', 'b1', 'W2', 'b2'.

    Can anyone suggest what might be causing the autograder to fail all tests, even though the cost value looks correct?

    Continue reading...

Compartilhe esta Página