Course 04 W04 "Neural Style Transfer" programming assignment ISSUE

Could someone please help me debug this assignment and why is this error . Thank you
{image removed by moderator as it contained codes from grader cell}

1 Like

Dear @Radhwane_BENAISSA,

Please check the declaration/initialization of ‘x’ and ‘y’ variable.
Error is clearly showing the data type mismatch.

1 Like

Hi @Radhwane_BENAISSA

Firstly it is a request refrain from posting any codes related to grader cells, it is against community guidelines, doing so can revoke your membership in the discourse community.

Issue with your codes.

  1. The way you recalled below codes is incorrect
    Reshape the tensors from (1, n_H, n_W, n_C) to (n_C, n_H * n_W) (≈2 lines)
    Notice the instruction given to right this code before the grader cell is
    Unroll the hidden layer activations a_S and a_G into 2D matrices, as explained in the picture above (see the images in the sections “computing the content cost” and “style matrix”).

Another important hint is
Since the activation dimensions are (m,nH,nW,nC) whereas the desired unrolled matrix shape is (nC, nH∗nW), the order of the filter dimension nC is changed. So tf.transpose can be used to change the order of the filter dimension.

So make you first use tf.reshape on the style image S and G with matrix shape, to this you need to use tf.transpose. Also there is also mention the order of filter dimension nC is changed, when you do the reshape mentioned nC first and then nH*nW

  1. Next issue Computing gram_matrices for both images S and G (≈2 lines)
    Compute the Style matrix of the images S and G. (Use the function you had previously written.)
    Gram matrix of the “style” image(a_S)
    Gram matrix of the “generated” image(a_G).

  2. This code is totally incorrectly written
    Computing the loss (≈1 line)
    Refer the below image to write the correct code

Your equation should begin with loss mentions first on the dimensions to which you multiple the tf.reduce_sum is used to the tf.pow of style matrix of images of S-G) of 2

Regards
DP