tensorflow - tf.initialize_all_variables() 和 tf.global_variables_initializer() 之间有什么区别

标签 tensorflow

在Tensorflow官网上,给出了tf.initialize_all_variables()tf.global_variables_initializer()函数的解释如下

tf.initialize_all_variables():

Returns an op that initializes all variables.

tf.global_variables_initializer():

Adds an op to initialize all variables in the model

似乎两者都可以用来初始化图中的所有变量。我们可以互换使用这两个函数吗?如果不是,会有什么差异?

最佳答案

不幸的是,您忘记阅读 tf.initialize_all_variables 文档中的重要一行.

THIS FUNCTION IS DEPRECATED. It will be removed after 2017-03-02. Instructions for updating: Use tf.global_variables_initializer instead.

关于tensorflow - tf.initialize_all_variables() 和 tf.global_variables_initializer() 之间有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41439254/

相关文章:

python - 如何正确使用 mask_zero=True 进行预训练权重的 Keras 嵌入?

python - tensorflow 抛出 "model_dir should be non-empty"

TensorFlow Batch 外积

tensorflow - 我应该对所有函数使用 @tf.function 吗?

machine-learning - 神经网络模型不学习?

python - Tensorflow找不到GPU

python - 在 GPU 上运行时使用 TensorFlow 内存 : why does it look like not all memory is used?

tensorflow - 在 tensorflow 中读取大型训练/验证/测试数据集

python - 使用 cuda 10 安装 pip tensorflow-gpu 后出错

python - 同时运行多个预训练的 Tensorflow 网络