I am currently finishing up all the remaining assignments of Course 4 of the TFAT specialization. There is one assignment in particular with which I am having extreme difficulty obtaining the desired final result. More specifically, I’m referring to the Dog Style Transfer assignment.
When I run the inception model on the images without adjusting any of the hyperparameters (as indicated in the notebook), I end up with a stylized image that is extremely noisy and grainy. It is very difficult to make out the dog in the image.
Despite having checked my notebook for potential coding errors and compared it to the ungraded lab at least a dozen times, I am unable to determine why my stylized image is producing such a low similarity index (roughly 0.2-0.3) every time I run the cell. I’ve tried tweaking the style and content layers, the corresponding weights and even the number of epochs (even though I’m supposed to leave the latter two parameters alone), but to no avail. When I adjust the style weight to about 1e-5, I get an image that is a lot less grainy, but still produces a low index.
I don’t really know what more I can do to achieve the desired result. Any assistance would be greatly appreciated.
To take a guess is difficult, perhaps you are not using the right content and style layers or most probably not calculating the righ total loss, or maybe you are not training the model properly…
I think its best to refresh the entire notebook and do it from the begining.
I’ve been using the same style and content layers as specified in the notebook for each of my model runs. A recurring problem I’ve read about for other people having similar issues is the order in which the layers are concatenated. However, I made sure to place the style layers before the content layer. I also checked my total loss multiple times for any possible errors and compared it to the one in the ungraded lab, but everything checks out.
Can I share my notebook with you so you can see what’s going on?
I figured that since the weights are set to imagenet by default that I wouldn’t have to explicitly write out this setting. Unless there is a separate step that you’re referring to that I missed.
Nonetheless, I did what you suggested and the result is still unfortunately the same.
Sorry I can not see any problems through my inspection of the notebook. I would suggest at this point maybe perform a force refresh and redo it entirely.
I went back to the notebook and paid more attention to it this time,
at get_style_loss(features, targets) you are not supposed to use tf.reduce_sum() but it says "The style loss is the average of the squared differences "…
Try this now I think this should solve your problem (it actually does) and I am also testing it right now myself with this change, but if still persists send over the notebook to @Pere_Martra his eye might catch it!
Thank you for referring me to this post. Fortunately, Gent spotted the error that was preventing the notebook from outputting the desired result. I was able to fix it in no time.
Nonetheless, I very much appreciate your offer of assistance!