DLS Course 4 Week4 A2: Total cost J is too high!

Hi, My train_step() function is returning too high total cost (AssertionError: Unexpected cost for epoch 0: 2078114.625 != 25629.055). I am computing a_G by passing ‘generated_image’ to ’ vgg_model_outputs. And Then using a_G, and precomputed a_S, and a_C to compute the costs as suggested. All the cost functions passed the tests. Any clue what might be wrong?

One problem is that this notebook is “stateful”: you can’t run train_step several times and get consistent answers. The first thing to try is:

  1. Kernel → Restart and Clear Output
  2. Cell → Run All

Then check your outputs from the test that runs train_step.

If it’s still wrong, then we can go to the next step.

Well, maybe that theory won’t help. I tried a few experiments with running train_step several times and I get wrong values, but not “crazy high” values like the one you show. So I think there is probably something more wrong in your code.

The issue was similar to this: Week 4 Assignment 2 Exercise 6 Issue

And, it worked.

I’m glad to hear you were able to find the solution. Sorry that I didn’t think to suggest the integer arithmetic issues. Normally those throw negative values. Here is a thread which goes into more detail on that.

1 Like