簡體   English   中英

運行tf contrib學習線性回歸示例時發出警告

[英]Warning when run tf contrib learn linear regression example

以下代碼引發了在代碼之后發布的一些警告。 它有什么問題以及如何修復它們。

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.

警告:tensorflow:來自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將基於創建它們的范圍自動刪除摘要名稱。此外,不再支持將張量或標簽列表傳遞到標量摘要操作。

警告:tensorflow:一列的輸入張量(1)的等級應與output_rank(2)相同。 將嘗試擴大昏暗。 強烈建議您調整輸入大小,因為這種行為可能會改變。

警告:tensorflow:來自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將基於創建它們的范圍自動刪除摘要名稱。此外,不再支持將張量或標簽列表傳遞到標量摘要操作。

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.

警告:tensorflow:來自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將基於創建它們的范圍自動刪除摘要名稱。此外,不再支持將張量或標簽列表傳遞到標量摘要操作。

WARNING:tensorflow: Skipping summary for global_step, must be a float or np.float32.

火車損失:{'loss':6.2396435e-09,'global_step':1000}

評估損失:{'loss':0.0025317217,'global_step':1000}

對於第一個,將model_dir =顯式傳遞給LinearRegressor init 這樣,您就知道它在哪里。

不確定輸入輸出等級警告是什么。 但是所有其他內容都在Estimator內部,因此您不必擔心並且無法修復。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM