Use zip
Wrong : gen_optimizer.apply_gradients(gen_gradient , generator.trainable_variables)
This will give error :
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/optimizer_v2/utils.py in filter_empty_gradients(grads_and_vars) 65 filtered = [] 66 vars_with_empty_grads = [] ---> 67 for grad, var in grads_and_vars: 68 if grad is None: 69 vars_with_empty_grads.append(var)
ValueError: too many values to unpack (expected 2)
The reason is zip is not used
Correct :gen_optimizer.apply_gradients(zip(gen_gradient , generator.trainable_variables))
No comments:
Post a Comment