Hi,
I’m working on the train_step of week 4 assignment 2.
I’m in the for loop, directionally i’m:
getting the vgg_model_outputs for the current image
computing the style cost using the style layers and current image
computing the content cost using the content layers and the current image
using those to compute the total cost. it seems straightforward, and when i try to debug my issue, im not getting errors until i try to compute the total cost. it’s giving me the folllowing however:
ValueError Traceback (most recent call last)
Input In [84], in <cell line: 7>()
1 ### you cannot edit this cell
2
3 # You always must run the last cell before this one. You will get an error if not.
5 generated_image = tf.Variable(generated_image)
----> 7 train_step_test(train_step, generated_image)
File /tf/W4A2/public_tests.py:86, in train_step_test(target, generated_image)
82 def train_step_test(target, generated_image):
83 generated_image = tf.Variable(generated_image)
---> 86 J1 = target(generated_image)
87 print(J1)
88 assert type(J1) == EagerTensor, f"Wrong type {type(J1)} != {EagerTensor}"
File /usr/local/lib/python3.8/dist-packages/tensorflow/python/util/traceback_utils.py:153, in filter_traceback.<locals>.error_handler(*args, **kwargs)
151 except Exception as e:
152 filtered_tb = _process_traceback_frames(e.__traceback__)
--> 153 raise e.with_traceback(filtered_tb) from None
154 finally:
155 del filtered_tb
File /tmp/__autograph_generated_filel5ri0qpt.py:17, in outer_factory.<locals>.inner_factory.<locals>.tf__train_step(generated_image)
15 J_content = ag__.converted_call(ag__.ld(compute_content_cost), (ag__.ld(a_C), ag__.ld(a_G)), None, fscope)
16 ag__.ld(print)('here2')
---> 17 J = ag__.converted_call(ag__.ld(compute_content_cost), (ag__.ld(J_content), ag__.ld(J_style)), None, fscope)
18 grad = ag__.converted_call(ag__.ld(tape).gradient, (ag__.ld(J), ag__.ld(generated_image)), None, fscope)
19 ag__.converted_call(ag__.ld(optimizer).apply_gradients, ([(ag__.ld(grad), ag__.ld(generated_image))],), None, fscope)
File /tmp/__autograph_generated_filequpmd2t3.py:11, in outer_factory.<locals>.inner_factory.<locals>.tf__compute_content_cost(content_output, generated_output)
9 do_return = False
10 retval_ = ag__.UndefinedReturnValue()
---> 11 a_C = ag__.ld(content_output)[(- 1)]
12 a_G = ag__.ld(generated_output)[(- 1)]
13 (_, n_H, n_W, n_C) = ag__.ld(a_G).shape
ValueError: in user code:
File "<ipython-input-67-3cdf8296a584>", line 32, in train_step *
J = compute_content_cost(J_content, J_style)
File "<ipython-input-4-07b830dad426>", line 15, in compute_content_cost *
a_C = content_output[-1]
ValueError: Index out of range using input dim 0; input has only 0 dims for '{{node strided_slice}} = StridedSlice[Index=DT_INT32, T=DT_FLOAT, begin_mask=0, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=1](mul_10, strided_slice/stack, strided_slice/stack_1, strided_slice/stack_2)' with input shapes: [], [1], [1], [1] and with computed input tensors: input[3] = <1>.
It seems so straightforward im worried i have an issue in a previous function that the unit tests didnt uncover. Any hints appreciated!
Best,
Matt