title: I have a problem with the backpropagation of custom set of trainable variables
body: <p>I am training the neural network by selecting custom set of variables with</p>
  <pre><code>  tvars =  model.trainable_variables
    g_vars = [var for var in tvars if 'param' in var.name]
    optimizer.apply_gradients(zip(gradients_of_discriminator,g_vars))
  </code></pre>
  <p>the optimizer is</p>
  <pre><code>optimizer = tf.keras.optimizers.Adam(1e-4)
  </code></pre>
  <p>the gradients are taken with</p>
  <pre><code>with tf.GradientTape() as tape:
    disc_loss = discriminator_loss(real_output, fake_output)
    loss = compute_loss_labeled(model, x,label) 
  gradients_of_discriminator = tape.gradient(loss, model.trainable_variables)
  </code></pre>
  <p>the error is</p>
  <pre><code>InvalidArgumentError:  var and grad do not have the same shape[11] [1]
   [[node Adam/Adam/update_13/ResourceApplyAdam (defined at &lt;ipython-input-1-ad3fd128f89e&gt;:343) ]] [Op:__inference_train_step_normal_label_12257]
  
  Errors may have originated from an input operation.
  Input Source operations connected to node Adam/Adam/update_13/ResourceApplyAdam:
  model_1/param_9/BiasAdd/ReadVariableOp/resource (defined at &lt;ipython-input-1-ad3fd128f89e&gt;:331) 
  gradient_tape/sequential_1_1/conv2d_transpose_2/BiasAdd/BiasAddGrad (defined at &lt;ipython-input-1-ad3fd128f89e&gt;:337) 
  model_1_1/param_9/BiasAdd/ReadVariableOp (defined at &lt;ipython-input-1-ad3fd128f89e&gt;:332)
  
  Function call stack:
  train_step_normal_label
  </code></pre>