Course 4 week4 ex6

I can’t seem to get my train step function to pass and not clear of the issue.

Currently I have:

# UNQ_C5
# GRADED FUNCTION: train_step

optimizer = tf.keras.optimizers.Adam(learning_rate=0.01)

@tf.function()
def train_step(generated_image):
    with tf.GradientTape() as tape:
        # In this function you must use the precomputed encoded images a_S and a_C
  
        ### START CODE HERE
         {moderator edit: solution code removed}     
              
        ### END CODE HERE
        
    grad = tape.gradient(J, generated_image)

    optimizer.apply_gradients([(grad, generated_image)])
    generated_image.assign(clip_0_1(generated_image))
    # For grading purposes
    return J

I get a ValueError: not enough values to unpack (expected 4, got 3)
It feels like my line with compute content cost may be wrong, but I can’t see the error.

@yunti please keep in mind that it is against forum rules to post your code-- One of the moderators will likely remove it (I don’t make up the rules, only abide by them).

That said, these are the two lines you want to look at more closely:

        # Compute the content cost
        J_content = 
        # Compute the total cost
        J = 

For the later J… Well we already have a cost function we developed earlier in the lesson, no ? I’d use that.

For J_content I’d pay closer attention to what (and why) you are indexing.

1 Like

Got it thanks.