Tensorflow不支持的Feed类型

时间:2017-11-09 01:20:28

标签: tensorflow

希望有人在尝试执行WideAndDeep模型时可以帮助我解决此TensorFlow(1.3)错误。在我的理智的极限。

错误: tensorflow.python.framework.errors_impl.InternalError:不支持的Feed类型

完整筹码:

2017-11-09 00:42:06.024911: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Found device 0 with properties: 
name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235
pciBusID: 0000:00:1e.0
totalMemory: 11.17GiB freeMemory: 11.10GiB
2017-11-09 00:42:06.024939: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1055] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: Tesla K80, pci bus id: 0000:00:1e.0, compute capability: 3.7)
Traceback (most recent call last):
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1321, in _do_call
return fn(*args)
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1300, in _run_fn
status, run_metadata)
File "/home/centos/anaconda3/lib/python3.6/contextlib.py", line 89, in __exit__
next(self.gen)
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 467, in raise_exception_on_not_ok_status
c_api.TF_GetCode(status.status))
tensorflow.python.framework.errors_impl.InternalError: Unsupported feed type 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):    
File "BareBonesWideDeep.py", line 152, in <module>
train_and_eval('', 'wide_n_deep', 50,'', '')
File "BareBonesWideDeep.py", line 129, in train_and_eval
m.train(input_fn=input_fn(train_file_name, num_epochs=None, shuffle=True), steps=train_steps)
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 255, in train
loss = self._train_model(input_fn=input_fn, hooks=hooks)
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 717, in _train_model
_, loss = mon_sess.run([estimator_spec.train_op, estimator_spec.loss])
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 537, in __exit__
self._close_internal(exception_type)
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 574, in _close_internal
self._sess.close()
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 820, in close
self._sess.close()
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 941, in close
ignore_live_threads=True)
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/coordinator.py", line 389, in join
six.reraise(*self._exc_info_to_raise)
File "/home/centos/anaconda3/lib/python3.6/site-packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/inputs/queues/feeding_queue_runner.py", line 94, in _run
sess.run(enqueue_op, feed_dict=feed_dict)
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 889, in run
run_metadata_ptr)
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1118, in _run
feed_dict_tensor, options, run_metadata)
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1315, in _do_run
options, run_metadata)
File "/home/centos/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InternalError: Unsupported feed type

我从搜索中看到的唯一一件事就是这个代码 它来自Tensorflow,正在进行从python到TF内部的数据映射,并抛出&#34; Unsupported feed type&#34;。 https://github.com/petewarden/tensorflow_makefile/blob/master/tensorflow/python/client/tf_session_helper.cc

打印我的要素数据类型会导致:

f_1     float64
f_2     float64
f_3     float64
f_4     float64
f_5     float64
f_6     float64
f_7     float64
f_8     float64
f_9     float64
f_10    float64
f_11    float64
f_12     object
f_13    float64

我在堆栈跟踪中的最后一个代码是m.train,它调用input_fcn:

print("Training.....")
print('num_epochs train_and_eval:' + str(train_steps))
m.train(input_fn=input_fn(train_file_name, num_epochs=None, 
shuffle=True), steps=train_steps)

def input_fn(data_file, num_epochs, shuffle):
    """Input builder function."""
    df_data = pd.read_csv('data.csv')
    df_data.fillna(0, inplace = True)
    df_data = df_data[df_data['y_actual_bucket']>=-4]
    df_data.f_12 = df_data.f_12.astype(str)
    df_data['f_12'] = 'a'
    print("CSV file data dimensions:",df_data.shape)
    print('num_epochs input_fn:' + str(num_epochs))
    labels = df_data["y_actual_bucket"]#.apply(lambda x: ">50K" in x).astype(int)
    labels = labels+4
    df_data = df_data.iloc[:,5:]
    train_test_cutoff = int(df_data.shape[0]*.7)
    if data_file == 'fake1':
      df_data = df_data.iloc[:train_test_cutoff,:]
      labels = labels.iloc[:train_test_cutoff]
      print("Training data shape:", df_data.shape)
    else:
      df_data = df_data.iloc[train_test_cutoff:,:]
      labels = labels.iloc[train_test_cutoff:]
      print("test data shape:", df_data.shape)  
    print(df_data.dtypes)
    return tf.estimator.inputs.pandas_input_fn(
        x=df_data,
        y=labels,
        batch_size=100,
        num_epochs=num_epochs,
        shuffle=shuffle,
        num_threads=1)

1 个答案:

答案 0 :(得分:1)

这是一个非常恼人且无用的错误消息。我通过将我的功能和标签强制转换为float32来解决它:

df2 = df1.apply(lambda x: x.astype('float32'))

我相信会出现此错误,因为tf.feature_column.numeric_column()默认为float32