python - 弃用警告 : How to remove tf. keras 警告 "calling VarianceScaling.__init__ with dtype is deprecated..."

标签 python tensorflow keras

以下代码在 tensorflow r1.12 python API 中生成警告:

#!/usr/bin/python3
import tensorflow as tf

M = tf.keras.models.Sequential();
M.add(tf.keras.layers.Dense(2)); 

完整的警告文本是这样的:

WARNING: Logging before flag parsing goes to stderr.
W0213 15:50:07.239809 140701996246848 deprecation.py:506] From /home/matias/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/init_ops.py:1253: calling VarianceScaling.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor

我尝试了不同的方法,比如在添加 Dense 层并将其传递给 Dense 构造函数之前初始化和调用内核初始化器,但它似乎没有改变任何东西。这个警告是不可避免的吗?回答"is"对我来说就足够了。

最佳答案

警告可能是由 abseil-py 上游引起的,它是 tensorflow 的依赖项。 查看详情here . 一个简单的修复可能是通过运行更新 abseil-py:

pip install --upgrade absl-py

(在我的例子中,冲突版本是 0.7.1,问题在更新版本 0.8.1 中得到修复)

关于python - 弃用警告 : How to remove tf. keras 警告 "calling VarianceScaling.__init__ with dtype is deprecated...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54677761/

相关文章:

python - Pandas 从列名列表中获取数据

python - 设置元素的同一列表的所有元素之间的交集

tensorflow - 属性错误 : The layer has never been called and thus has no defined input shape

python - 使用 keras 对图像进行 convnet 回归 - 精度不能提高超过 40%

python - 当模型具有注意力层时,无法从 Model.get_config() 加载 keras 中的模型

python - 按日期过滤 Pandas 数据框不起作用

Python GoogleSearch 模块错误 : "TypeError: search() got an unexpected keyword argument ' tld' "

python - 训练损失减少,开发损失增加

python-3.x - tensorflow (使用 Keras)中出现 'InvalidArgumentError: Incompatible shapes: [10,2] vs. [10]' 的原因是什么?

python - LSTM 的输入形状,具有一个热编码数据