gpt4 book ai didi

python-3.x - TensorFlow 0.12 教程产生警告 : "Rank of input Tensor should be the same as output_rank for column

转载 作者:行者123 更新时间:2023-12-04 02:06:53 32 4
gpt4 key购买 nike

我有一些用 python 编写机器学习程序的经验,但我是 TensorFlow 的新手,正在检查它。我的开发环境是一个 lubuntu 14.04 64 位虚拟机。我从 miniconda 创建了一个 python 3.5 conda 环境并安装了 TensorFlow 0.12 及其依赖项。我开始尝试运行 TensorFlow 教程中的一些示例代码,并在调用 fit() 时遇到此警告。在输入函数的 boston.py 示例中:source .

WARNING:tensorflow:Rank of input Tensor (1) should be the same as output_rank (2) for column. Will attempt to expand dims. It is highly recommended that you resize your input, as this behavior may change.



在谷歌搜索后,我发现其他人也遇到了同样的警告:
  • https://github.com/tensorflow/tensorflow/issues/6184
  • https://github.com/tensorflow/tensorflow/issues/5098
  • Tensorflow - Boston Housing Data Tutorial Errors

  • 但是,他们也遇到了阻止代码执行完成的错误。就我而言,代码执行时带有上述警告。不幸的是,我在这些链接中找不到关于导致警告的原因以及如何修复警告的单一答案。他们都专注于错误。如何删除警告?还是可以安全忽略该警告?

    干杯!

    额外信息,在运行上述 boston.py 示例时,我还会看到以下警告。

    WARNING:tensorflow:******************************************************* WARNING:tensorflow:TensorFlow's V1 checkpoint format has been deprecated. WARNING:tensorflow:Consider switching to the more efficient V2 format: WARNING:tensorflow:
    'tf.train.Saver(write_version=tf.train.SaverDef.V2)' WARNING:tensorflow:now on by default. WARNING:tensorflow:*******************************************************





    WARNING:tensorflow:From /home/kade/miniconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn_linear_combined.py:1053 in predict.: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01. Instructions for updating: Estimator is decoupled from Scikit Learn interface by moving into separate class SKCompat. Arguments x, y and batch_size are only available in the SKCompat class, Estimator will only accept input_fn. Example conversion: est = Estimator(...) -> est = SKCompat(Estimator(...))



    更新 (2016-12-22):
    我已经跟踪到这个文件的警告:
    https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/layers/python/layers/feature_column_ops.py

    这个代码块:
    except NotImplementedError:
    with variable_scope.variable_scope(
    None,
    default_name=column.name,
    values=columns_to_tensors.values()):
    tensor = column._to_dense_tensor(transformed_tensor)
    tensor = fc._reshape_real_valued_tensor(tensor, 2, column.name)
    variable = [
    contrib_variables.model_variable(
    name='weight',
    shape=[tensor.get_shape()[1], num_outputs],
    initializer=init_ops.zeros_initializer(),
    trainable=trainable,
    collections=weight_collections)
    ]
    predictions = math_ops.matmul(tensor, variable[0], name='matmul')

    注意这一行: tensor = fc._reshape_real_valued_tensor(tensor, 2, column.name)
    方法签名是: _reshape_real_valued_tensor(input_tensor, output_rank, column_name=None)
    2硬编码为 output_rank 的值,但 boston.py 示例传入 input_tensor排名第一。我会继续调查。

    最佳答案

    如果您明确指定张量的形状:

    tf.constant(df[k].values, shape=[df[k].size, 1]) 

    警告应该消失。

    关于python-3.x - TensorFlow 0.12 教程产生警告 : "Rank of input Tensor should be the same as output_rank for column,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41273182/

    32 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com