ChunyuLiu188 / Image-semantic-block-transmission-with-REINFORCE

Task-Oriented Image Transmission for Scene Classification Based on REINFORCE
4 stars 1 forks source link

optimize alternately in a function decorated with @tf.function #2

Open ChunyuLiu188 opened 1 year ago

ChunyuLiu188 commented 1 year ago

I want to alternate the optimization of parameters in the model. However, when the trainable variables are changed in a function decorated with @tf.function, I encounter the error message: "ValueError: tf.function only supports singleton tf.Variables created on the first call. Make sure the tf.Variable is only created once or created outside tf.function." My solution is creating three separate functions for different training stages. Are there any other approaches?