以下代码在代码后发布了一些警告。它有什么问题以及如何解决它们。
import tensorflow as tf
import numpy as np
features = [tf.contrib.layers.real_valued_column('x', dimension=1)]
estimator = tf.contrib.learn.LinearRegressor(feature_columns=features)
x_train = np.array([1., 2., 3., 4.])
y_train = np.array([0., -1., -2., -3.])
x_eval = np.array([2., 5., 8., 1.])
y_eval = np.array([-1.01, -4.1, -7, 0.])
input_fn = tf.contrib.learn.io.numpy_input_fn(
{'x':x_train}, y_train,
batch_size=4,
num_epochs=1000)
eval_input_fn = tf.contrib.learn.io.numpy_input_fn(
{'x':x_eval}, y_eval, batch_size=4, num_epochs=1000)
estimator.fit(input_fn=input_fn, steps=1000)
train_loss = estimator.evaluate(input_fn=input_fn)
eval_loss = estimator.evaluate(input_fn=eval_input_fn)
print('train loss: %r'% train_loss)
print('eval loss: %r'% eval_loss)
=============================================== ========================
警告:tensorflow:使用临时文件夹作为模型目录:C:\Users\user\AppData\Local\Temp\tmprlxunsfy
WARNING:tensorflow: Rank of input Tensor (1) should be the same as output_rank (2) for a column. Will attempt to expand dims. It is highly recommended that you resize your input, as this behavior may change.
警告:张量流:来自C:\python\Python352\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\head.py:615: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.
更新说明:
请切换到tf.summary.scalar。请注意,tf.summary.scalar使用节点名称而不是标记。这意味着TensorFlow将根据创建的范围自动对摘要名称进行重复数据删除。此外,不再支持将张量或标记列表传递给标量摘要op。
警告:tensorflow:输入的等级Tensor(1)应与列的output_rank(2)相同。将尝试扩大dims。强烈建议您调整输入大小,因为此行为可能会发生变化。
警告:张量流:来自C:\python\Python352\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\head.py:615: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.
更新说明:
请切换到tf.summary.scalar。请注意,tf.summary.scalar使用节点名称而不是标记。这意味着TensorFlow将根据创建的范围自动对摘要名称进行重复数据删除。此外,不再支持将张量或标记列表传递给标量摘要op。
WARNING:tensorflow: Skipping summary for global_step, must be a float or np.float32.
WARNING:tensorflow: Rank of input Tensor (1) should be the same as output_rank (2) for a column. Will attempt to expand dims. It is highly recommended that you resize your input, as this behavior may change.
警告:张量流:来自C:\python\Python352\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\head.py:615: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.
更新说明:
请切换到tf.summary.scalar。请注意,tf.summary.scalar使用节点名称而不是标记。这意味着TensorFlow将根据创建的范围自动对摘要名称进行重复数据删除。此外,不再支持将张量或标记列表传递给标量摘要op。
WARNING:tensorflow: Skipping summary for global_step, must be a float or np.float32.
火车损失:{'亏损':6.2396435e-09,' global_step':1000}
eval loss:{' loss':0.0025317217,' global_step':1000}
答案 0 :(得分:0)
对于第一个,将model_dir =显式传递给LinearRegressor init 。这样你就知道它在哪里。
不确定输入输出等级警告是什么。但是所有其他内容都是Estimator的内部信息,因此您不必担心并且无法修复。