[Image Style Transfer] Correct Gram Matrix function for Batch Size > 1 #167
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Dear Udacity team,
Description
I noted that the gram matrix implementation in the
Style_Transfer_Solution.ipynbdoesn't take account if the tensors inputs are feature map from batch sizeb > 1.While the notebook exercise doesn't use multiple content/style image at the same time, I would suggest that the gram matrix implementation takes into account the case for having
b > 1. Thus assuming theb=1in the context of the gram matrix implementation alone confuses me as a reader as it seems to discardbatch sizeinformation in a general gram matrix implementation, while it should not.Suggestion
Hence I edited the output tensors of
gram_matrix()similar to the following:Given batch size
bof style image feature maps in the form of 4D tensors, theget_gram_matrix(imgs)does the operation of gram matrix for each batch size and stack the output matrix, hence resulting in the output of 2D with shape:(b*d, h*w)Thank you,
iqDF.