Machine learning 使用张量流神经网络中的自定义数据进行回归

Machine learning 使用张量流神经网络中的自定义数据进行回归,machine-learning,tensorflow,neural-network,deep-learning,Machine Learning,Tensorflow,Neural Network,Deep Learning,我正在训练一个神经网络,根据答案、评论和经过的天数来预测问题的观点数量。我的csv文件中的数据如下所示: 答案、评论、过去的日子、观点 2, 5, 20, 300 根据以上数据,我使用前3列作为特征,最后一列作为标签。我的文件包含3000个条目。我修改了此代码以训练我的神经网络: 但我在交叉验证时出错。我的代码就是这样的: filename_queue = tf.train.string_input_producer(["file0.csv"]) reader = tf.T

我正在训练一个神经网络,根据答案、评论和经过的天数来预测问题的观点数量。我的csv文件中的数据如下所示:

答案、评论、过去的日子、观点 2, 5, 20, 300 根据以上数据,我使用前3列作为特征,最后一列作为标签。我的文件包含3000个条目。我修改了此代码以训练我的神经网络:

但我在交叉验证时出错。我的代码就是这样的:

filename_queue = tf.train.string_input_producer(["file0.csv"])

reader = tf.TextLineReader()
key, value = reader.read(filename_queue)

# Default values, in case of empty columns. Also specifies the type of the
# decoded result.
record_defaults = [[1], [1], [1], [1]]
col1, col2, col3, col4 = tf.decode_csv(value, record_defaults=record_defaults)
features = tf.stack([col1, col2, col3])

with tf.Session() as sess:
  # Start populating the filename queue.
  coord = tf.train.Coordinator()
  threads = tf.train.start_queue_runners(coord=coord)

  for i in range(3000):
    # Retrieve a single instance:
    x, y = sess.run([features, col4])

  coord.request_stop()
  coord.join(threads)
 
X_train, X_test, Y_train, Y_test = cross_validation.train_test_split(x, y, test_size=0.2, random_state=42)
我在最后一行(交叉验证。训练测试分割)上遇到以下错误:


整个错误的粘贴箱会更有帮助-在开始时通常会有一条更合理的消息traceback@dv3这就是整条消息,只缺少这一行(multilayer_reg.py),第45行,在x,y中,test_size=0.2,random_state=42)).我觉得问题出在x&y变量上,但无法计算出确切的数值problem@dv3通过使用此循环(对于范围(3000)中的i),我希望我的所有功能都存储在变量“X”中,所有标签都存储在变量“Y”中,但似乎X和Y只包含第一个条目。为什么不先使用train_test_split将文件拆分为测试和培训CSV,然后使用TF对train文件进行培训并对测试文件进行测试?