Timeline for Understanding the intuition behind Content Loss (Neural Style Transfer)
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 2, 2019 at 13:39 | comment | added | Hazzaldo |
Oh ye of course. That makes sense now. It needed to be converted from Tensor to numpy array first to work with .T . Silly error on my part :) Thanks again.
|
|
Sep 2, 2019 at 13:30 | comment | added | Djib2011 | You're welcome :) | |
Sep 2, 2019 at 13:30 | comment | added | Djib2011 |
y_arr is the array that came out from K.eval(y) . It should be an array not a tensor.
|
|
Sep 2, 2019 at 11:37 | comment | added | Hazzaldo |
Thank you so much for your help :) Just a side note btw, y_arr.T did not work, as it was throwing an error: 'Tensor' object has no attribute 'T' . I tried tf.transpose(y_arr) and that worked. Thanks again. Really appreciate your help on this. :)
|
|
Sep 2, 2019 at 11:30 | vote | accept | Hazzaldo | ||
Aug 31, 2019 at 23:42 | comment | added | Djib2011 |
You can think of K.eval() as a method of converting tensors to arrays. It can't be applied to As because As is a list not a tensor. Instead it can be applied to the contents of the list, which happen to be tensors, e.g. K.eval(As[0]) for the first tensor from the list.
|
|
Aug 31, 2019 at 23:38 | comment | added | Djib2011 |
You first need to transpose the array to (4096, 512) . You can do this by y_arr = y_arr.T . Then you need to reshape it to the original dimensions: y_arr = y_arr.reshape((64, 64, 512)) . I don't think you can turn these into rgb images. I think this represents 512 grayscale feature maps. To get each you can simply slice the array, e.g. y_arr[:, :, 13] (for the image with index 13).
|
|
Aug 30, 2019 at 23:12 | comment | added | Hazzaldo | Sorry about the follow up questions. | |
Aug 30, 2019 at 23:11 | comment | added | Hazzaldo |
When I tried K.eval(As) I got the error message: 'list' object has no attribute 'eval' . When I print out As I get the output: [<tf.Tensor 'transpose_18:0' shape=(64, 262144) dtype=float32>, <tf.Tensor 'transpose_19:0' shape=(128, 65536) dtype=float32>, <tf.Tensor 'transpose_20:0' shape=(256, 16384) dtype=float32>, <tf.Tensor 'transpose_21:0' shape=(512, 4096) dtype=float32>]
|
|
Aug 30, 2019 at 23:11 | comment | added | Hazzaldo |
My second follow up question is, the eval() function did not work on the style representation tensor data structure (As ), for this code output: As = get_feature_reps(x=sImArr, layer_names=sLayerNames, model=sModel) .
|
|
Aug 30, 2019 at 23:10 | comment | added | Hazzaldo |
When I saved the array to an image with the shape (512, 4096) , the image looked completely weird: imgur.com/XHUlqtY It looks nothing like the original image: imgur.com/oZrBlX0
|
|
Aug 30, 2019 at 23:10 | comment | added | Hazzaldo |
Thank you so much for the response and clarification. Much appreciated. I did the K.eval(P) and it worked. P is the output content representation tensor: P = get_feature_reps(x=cImArr, layer_names=[cLayerName], model=cModel)[0] . Using K.eval(P) I got an output dtype of float32 and a shape of (512, 4096) . So just referring to your very last answer, for ensuring to convert to the correct format for RGB image, how do I convert a shape of (512, 4096) to the correct shape of (height, width, 3) .
|
|
Aug 29, 2019 at 19:20 | history | answered | Djib2011 | CC BY-SA 4.0 |