python - tensorflow no_grad 概念

标签 python tensorflow pytorch

我知道使用 pytorch,您可以通过在模型上调用 eval() 来关闭训练。 您还可以设置requires_grad=False

如何确保 TensorFlow 元素在训练期间不被修改?

最佳答案

如果您不想在 TensorFlow 中训练某些变量,可以通过向变量添加 trainable=False 来实现此行为。

关于python - tensorflow no_grad 概念,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56501260/

相关文章:

python - Python 中的年和日日期差异(无月)

python - 用 NLTK (python) 词干词干

python - Django objects.update_or_create

python - 类型错误 : wrapper() takes 1 positional argument but 2 were given

python - 类型错误 : unsupported operand type(s) for +: 'dict_items' and 'dict_items'

python - 警告 :tensorflow:AutoGraph could not transform <function _preprocess at 0x7f8ff80cd160> and will run it as-is

python - 如何修复属性错误: module 'tensorflow' has no attribute 'reset_default_graph'

python - 导入错误default_collat​​e未定义

python - PyTorch:如何使用 multiprocessing.pool 在多个 GPU 上并行化

torch - PyTorch 中的无量纲转置