Course 4 week 4 assignment 2 excercise 6 stuck

I’m a bit stuck on Excercise 6 with this output when I run the test:

AssertionError: Unexpected cost for epoch 0: 60808.39453125 != 25629.055

I suspect the issue is that I’m calculating J_content incorrectly. The excercise suggests that there will be 2 lines of code needed. I can only come up with one line: a call compute_content_test using a_C and a_G as the parameters.

Thanks for any advice!

The lines of code suggestions are just that: suggestions. They don’t check your actual source code. But note that the “2 lines” there refers to both computing the content cost and the total cost, which would be two separate lines of code.

What you described sounds correct, of course, so there must be more at work here. One thing to note is that there is statefulness in the train_step function, so you can’t just execute the “test” cell for that function multiple times: you have to separately rerun the train_step cell each time first. One way to make sure you aren’t seeing some side effect of that is just to run everything from a clean state:

Kernel -> Restart and Clear Output
Save
Cell -> Run All

Then read through and see if you still get the incorrect cost at epoch 0. If so, then maybe it’s time to look at your code. We can’t do that in a public thread, but please check your DMs for a message from me about how to proceed.

1 Like

note that the “2 lines” there refers to both computing the content cost and the total cost

Good point. I’ve made this mistake in the past of assuming a comment was referring to just the line directly below it.

To close the loop on the public thread, the code was correct, but the values that control how we define what we use for the “style” had been changed to this:

STYLE_LAYERS = [
    ('block3_conv3', 0.3),
    ('block3_conv4', 0.25),
    ('block4_conv1', 0.2),
    ('block4_conv2', 0.15),
    ('block4_conv3', 0.1)]

Whereas they originally gave us this to define the style:

STYLE_LAYERS = [
    ('block1_conv1', 0.2),
    ('block2_conv1', 0.2),
    ('block3_conv1', 0.2),
    ('block4_conv1', 0.2),
    ('block5_conv1', 0.2)]

It’s great to do this kind of experiment to see what kind of effects you can get, but it will change the cost values that you get. :nerd_face:

There have been some other threads over time where people showed various experiments based on this assignment. Here’s one that I remember from a few months ago that was interesting, but those experiments are by taking extreme values for the weighting of the content versus style costs.

Thank you Paul!

I seems pretty obvious now that I should not have modified that block since every place where we do need to make an input is clearly marked with “YOUR CODE HERE”.

2 Likes

I allowed myself to experiment a bit more as part of the ‘Art Generation with Neural Style Transfer’ lab. It helped me gain a deeper understanding of the topic. I’ve summarized my findings in a short post.

2 Likes