英文:
Saving symbolic Tensor for later use
问题
我正在跟随 TensorFlow 的教程学习一个聊天机器人,想知道如何在后续步骤中保存编码器的输出?我知道符号张量的值可以用 tf.print 打印出来,也可以写入 tf.TensorArray 中。由于聊天机器人模型的结构,全局变量不会受到训练过程中对它们所做更改的影响,那么在训练期间如何将这些张量保存在诸如 tf.TensorArray 中以备后续迭代使用呢?
英文:
I am following the tutorial from TensorFlow for a chatbot and was wondering how you could save the output of the encoder later passes? I know the values of symbolic tensors can be printed out with tf.print and they can be written into tf.TensorArray's. Because of how the chatbot model is structured, global variables will not be affected by changes made to them during training, so how does one save these tensors in things like tf.TensorArray's for later iterations during training?
答案1
得分: 0
如果您使用 run_eagerly=True
编译您的模型,那么您可以在训练过程中正确使用全局变量。如果您想在批次之间保存符号张量,那就会变得有点困难,所以我选择将我的层作为不使用符号张量的类来实现。
英文:
If you compile your model with run_eagerly=True
then you can properly use global variables during training. If you want to save symbolic tensors between batches, it gets a little more difficult so I opted to make my layers as classes that don't use symbolic tensors instead.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论