训练步骤中标签出错:InvalidArgumentError:断言失败:[标签ID必须> = 0]

时间:2018-05-07 08:11:45

标签: python python-3.x networking tensorflow input

我是Tensorflow的新手,我希望我能在这里得到一些帮助,我试图创建一个获得四个输入和一个输出的神经网络,它在Tensorflow中看起来像一个简单的任务,但是我是仍然会收到此错误:

  

InvalidArgumentError:断言失败:[标签ID必须> = 0]   [条件x> = 0不符合元素:] [x(dnn / head / ToFloat:0)   =] [[0] [0] [0] ...] [[节点:dnn / head / assert_range / assert_non_negative / assert_less_equal / Assert / AssertGuard / Assert = Assert [T = [DT_STRING,DT_STRING,DT_STRING,DT_FLOAT], summarize = 3,_device =" / job:localhost / replica:0 / task:0 / device:CPU:0"](dnn / head / assert_range / assert_non_negative / assert_less_equal / Assert / AssertGuard / Assert / Switch ,   DNN /头/ assert_range / assert_non_negative / assert_less_equal /断言/ AssertGuard /断言/ Data_0的,   DNN /头/ assert_range / assert_non_negative / assert_less_equal /断言/ AssertGuard /断言/ _1,   DNN /头/ assert_range / assert_non_negative / assert_less_equal /断言/ AssertGuard /断言/ _2,   DNN /头/ assert_range / assert_non_negative / assert_less_equal /断言/ AssertGuard /断言/交换机_1)]]

这是我的代码,提前谢谢。

F1 = tf.feature_column.numeric_column('F1')
F2 = tf.feature_column.numeric_column('F2')
F3 =tf.feature_column.numeric_column('F3')
F4 = tf.feature_column.numeric_column('F4')
F5 =tf.feature_column.numeric_column('F5')
F6 = tf.feature_column.numeric_column('F6')
F7  = tf.feature_column.numeric_column('F7')
F8 = tf.feature_column.numeric_column('F8')
F9 = tf.feature_column.numeric_column('F9')
F10  = tf.feature_column.numeric_column('F10')
F11 = tf.feature_column.numeric_column('F11')
F12  = tf.feature_column.numeric_column('F12')
F13 = tf.feature_column.numeric_column('F13')

deep_columns = [F2, F6, F11,F5]


COLUMNS = ["F1", "F2", "F3", 
"F4", "F5", "F6", "F7", 
"F8", "F9", "F10", "F11",  
"F12"]

df_train = pd.read_csv("C:/data_4.csv", 
names=COLUMNS, sep = "\t",skiprows=1,skipinitialspace=True)
df_train = df_train.fillna(0)
Xtrain = df_train.drop("F7", axis=1)  
y_train = pd.DataFrame(df_train.F7)
ytrain['F7'] = df_train.F7
ytrain = ytrain.astype(int) 

estimator = tf.estimator.DNNClassifier(
 feature_columns=deep_columns,
 hidden_units=[7, 10, 20])

inp = tf.estimator.inputs.pandas_input_fn(Xtrain,ytrain, 
    batch_size= 128,
    num_epochs=1,
    shuffle=True,
    queue_capacity=1000,
    num_threads=1,
    target_column='F7')

estimator.train(input_fn=inp,steps=200)

0 个答案:

没有答案