Programming Assignment "Gradient Checking": Suggestion to add a bit of printout to Exercise 4

In “Exercise 4”, this little printout is of great help. Maybe one might want to add it to the exercise code.

Directly after the for loop:

    # END FOR LOOP

    # Printing the results
    gradapprox_dict = vector_to_dictionary(gradapprox)
    grad_dict = vector_to_dictionary(grad)
    for name in ["W1", "b1", "W2", "b2", "W3", "b3"]:
        print(f"grad for {name}\n{grad_dict[name]}", file=sys.stderr)
        print(f"gradapprox for {name}\n{gradapprox_dict[name]}", file=sys.stderr)

    numerator = ....
    denominator = ...

    print(f"numerator = {numerator}", file=sys.stderr)
    print(f"denominator = {denominator}", file=sys.stderr)

    difference = ...

    print(f"difference = {difference}", file=sys.stderr)
2 Likes

@dtonhofer Yes I agree and it is always helpful and also give you better understanding.

1 Like