The problem most likely is to do with how you handle the scalar values in that computation. You have to be careful not to use TF functions for computing the scalar values, because they have very different type coercion rules. Either use python or numpy for the scalar parts and only use the TF functions for the tensors. Here’s a thread which discusses issues related to this.
According to your reply, I double checked my styly_cost function.
The issue is the "(tf.square(n_Cn_Hn_W) " , my original statement:
J_style_layer = (1. /(4. * float(tf.square(n_Cn_Hn_W) ) )) * tf.reduce_sum(tf.square(tf.subtract(GS,GG)))
I have changed to :
J_style_layer = (1 /(4 * (n_Cn_Hn_W)**2 ) ) * tf.reduce_sum(tf.square(tf.subtract(GS,GG)))
The error disappears.
Thanks very much.