Art_Generation_with_Neural_Style_Transfer, Exercise 6 - train_step: Can someone help me understand this function? I’m still very confused although I was able to get full grade.
how is generated_image updated? I don’t see it got assigned anywhere inside the function.
why do we need to use @tf.function()?
Why cannot we use the old way of training the model like calling model.fit like how we did in the unet model?
Thanks!
So what we did there was build a custom training loop for transferring the style.
We’re updating the image in the line where we’re applying the gradients to it later in the function
We could do it without tf.function, but the execution being in eager mode will be slow. With tf. function, it’ll be faster because that converts the function into a static graph.
You can actually use model.fit with custom training loops, but it’d have to be defined differently than here.
I’ll link a couple readings from tensorflow’s documentation for you to understand custom training loops better.