TMosh, I appreciate the help. In digging into the a_S and a_G parameters, I’m not sure where the error lies. Instrumenting with a few print statements through the final pass, a_S and a_G are in sync, the shapes are changing through the CNN, and it gets the correct cost for the first pass, only failing on the second. If the shapes were wrong, wouldn’t it also fail at the first pass through?
**VGG a_G**
**[<tf.Tensor 'functional_1/block1_conv1/Relu:0' shape=(1, 400, 400, 64) dtype=float32>, <tf.Tensor 'functional_1/block2_conv1/Relu:0' shape=(1, 200, 200, 128) dtype=float32>, <tf.Tensor 'functional_1/block3_conv1/Relu:0' shape=(1, 100, 100, 256) dtype=float32>, <tf.Tensor 'functional_1/block4_conv1/Relu:0' shape=(1, 50, 50, 512) dtype=float32>, <tf.Tensor 'functional_1/block5_conv1/Relu:0' shape=(1, 25, 25, 512) dtype=float32>, <tf.Tensor 'functional_1/block5_conv4/Relu:0' shape=(1, 25, 25, 512) dtype=float32>]**
**a_G Original**
**Tensor("functional_1/block1_conv1/Relu:0", shape=(1, 400, 400, 64), dtype=float32)**
**a_S Style**
**(64, 160000)**
**a_G Style**
**(64, 160000)**
**Tensor("transpose_1:0", shape=(64, 160000), dtype=float32)**
**a_G Original**
**Tensor("functional_1/block2_conv1/Relu:0", shape=(1, 200, 200, 128), dtype=float32)**
**a_S Style**
**(128, 40000)**
**a_G Style**
**(128, 40000)**
**Tensor("transpose_5:0", shape=(128, 40000), dtype=float32)**
**a_G Original**
**Tensor("functional_1/block3_conv1/Relu:0", shape=(1, 100, 100, 256), dtype=float32)**
**a_S Style**
**(256, 10000)**
**a_G Style**
**(256, 10000)**
**Tensor("transpose_9:0", shape=(256, 10000), dtype=float32)**
**a_G Original**
**Tensor("functional_1/block4_conv1/Relu:0", shape=(1, 50, 50, 512), dtype=float32)**
**a_S Style**
**(512, 2500)**
**a_G Style**
**(512, 2500)**
**Tensor("transpose_13:0", shape=(512, 2500), dtype=float32)**
**a_G Original**
**Tensor("functional_1/block5_conv1/Relu:0", shape=(1, 25, 25, 512), dtype=float32)**
**a_S Style**
**(512, 625)**
**a_G Style**
**(512, 625)**
**Tensor("transpose_17:0", shape=(512, 625), dtype=float32)**
**J_style**
**Tensor("add_4:0", shape=(), dtype=float32)**
**a_C**
**(1, 625, 512)**
**a_G**
**(1, 625, 512)**
**J_content**
**Tensor("mul_10:0", shape=(), dtype=float32)**
**VGG a_G**
**[<tf.Tensor 'functional_1/block1_conv1/Relu:0' shape=(1, 400, 400, 64) dtype=float32>, <tf.Tensor 'functional_1/block2_conv1/Relu:0' shape=(1, 200, 200, 128) dtype=float32>, <tf.Tensor 'functional_1/block3_conv1/Relu:0' shape=(1, 100, 100, 256) dtype=float32>, <tf.Tensor 'functional_1/block4_conv1/Relu:0' shape=(1, 50, 50, 512) dtype=float32>, <tf.Tensor 'functional_1/block5_conv1/Relu:0' shape=(1, 25, 25, 512) dtype=float32>, <tf.Tensor 'functional_1/block5_conv4/Relu:0' shape=(1, 25, 25, 512) dtype=float32>]**
**a_G Original**
**Tensor("functional_1/block1_conv1/Relu:0", shape=(1, 400, 400, 64), dtype=float32)**
**a_S Style**
**(64, 160000)**
**a_G Style**
**(64, 160000)**
**Tensor("transpose_1:0", shape=(64, 160000), dtype=float32)**
**a_G Original**
**Tensor("functional_1/block2_conv1/Relu:0", shape=(1, 200, 200, 128), dtype=float32)**
**a_S Style**
**(128, 40000)**
**a_G Style**
**(128, 40000)**
**Tensor("transpose_5:0", shape=(128, 40000), dtype=float32)**
**a_G Original**
**Tensor("functional_1/block3_conv1/Relu:0", shape=(1, 100, 100, 256), dtype=float32)**
**a_S Style**
**(256, 10000)**
**a_G Style**
**(256, 10000)**
**Tensor("transpose_9:0", shape=(256, 10000), dtype=float32)**
**a_G Original**
**Tensor("functional_1/block4_conv1/Relu:0", shape=(1, 50, 50, 512), dtype=float32)**
**a_S Style**
**(512, 2500)**
**a_G Style**
**(512, 2500)**
**Tensor("transpose_13:0", shape=(512, 2500), dtype=float32)**
**a_G Original**
**Tensor("functional_1/block5_conv1/Relu:0", shape=(1, 25, 25, 512), dtype=float32)**
**a_S Style**
**(512, 625)**
**a_G Style**
**(512, 625)**
**Tensor("transpose_17:0", shape=(512, 625), dtype=float32)**
**J_style**
**Tensor("add_4:0", shape=(), dtype=float32)**
**a_C**
**(1, 625, 512)**
**a_G**
**(1, 625, 512)**
**J_content**
**Tensor("mul_10:0", shape=(), dtype=float32)**
**tf.Tensor(25629.055, shape=(), dtype=float32)**
**tf.Tensor(13932.012, shape=(), dtype=float32)**
**---------------------------------------------------------------------------**
**AssertionError Traceback (most recent call last)**
**<ipython-input-27-c4cbeb243f35> in <module>**
** 10 J2 = train_step(generated_image)**
** 11 print(J2)**
**---> 12 assert np.isclose(J2, 17812.627, rtol=0.05), f"Unexpected cost for epoch 1: {J2} != {17735.512}"**
** 13 **
** 14 print("\033[92mAll tests passed")**
**AssertionError: Unexpected cost for epoch 1: 13932.01171875 != 17735.512**
Any hints on what the shape mismatch is?
Thanks!