Course 4 Week 4 Assignment 2 - Exercise 6 Selecting layer for generated_image

When coding the function for training:
def train_step(generated_image):

I get the generated_image layer values as:
a_G = vgg_model_outputs(generated_image)

Yet, when I run the test in the immediate next cell, I get:

AttributeError: in user code:

    File "<ipython-input-32-25b291707c26>", line 24, in train_step  *
        J_style = compute_layer_style_cost(a_S, a_G)
    File "<ipython-input-10-a4b70eac8075>", line 16, in compute_layer_style_cost  *
        m, n_H, n_W, n_C = a_G.get_shape().as_list()

    AttributeError: 'list' object has no attribute 'get_shape'

Printing the a_G gives the following output:

[<tf.Tensor 'model/block1_conv1/Relu:0' shape=(1, 400, 400, 64) dtype=float32>, <tf.Tensor 'model/block2_conv1/Relu:0' shape=(1, 200, 200, 128) dtype=float32>, <tf.Tensor 'model/block3_conv1/Relu:0' shape=(1, 100, 100, 256) dtype=float32>, <tf.Tensor 'model/block4_conv1/Relu:0' shape=(1, 50, 50, 512) dtype=float32>, <tf.Tensor 'model/block5_conv1/Relu:0' shape=(1, 25, 25, 512) dtype=float32>, <tf.Tensor 'model/block5_conv4/Relu:0' shape=(1, 25, 25, 512) dtype=float32>]

But I’m not able to select the layer of interest (block5_conv4).

How I do that?

1 Like

Ok… I was using compute_layer_style_cost(a_S, a_G) instead of compute_style_cost(a_S, a_G)

1 Like