Tensorflow - Python:如何在TensorFlow中使用我自己的数据?

时间:2016-06-21 11:33:00

标签: python tensorflow

我是TensorFow的新手,但我必须使用它,所以我有一个问题。

我必须在csv文件中使用特定数据,如下所示:

0.5,1,0,0,Slow_Start

1,2,0,0,Slow_Start

1.5,4,0,0,Slow_Start

2,8,0,0,Slow_Start

(Slow_Start是我必须使用的标签之一)。

我使用以下代码

成功导入了我的数据
directory = "/home/matthieu/Documents/python/*.csv"
filename_queue = tf.train.string_input_producer(
tf.train.match_filenames_once(directory),
shuffle=False)
line_reader = tf.TextLineReader()

_, csv_row = line_reader.read(filename_queue)
record_defaults = [[0.0], [0.0], [0.0], [0.0], [""]]
time, cwnd, rtt, dupack, Algo = \
tf.decode_csv(csv_row, record_defaults=record_defaults)
features = tf.pack([
    time,
    cwnd,
    rtt,
    dupack])

with tf.Session() as sess:
    tf.initialize_all_variables().run()

    coord = tf.train.Coordinator()
    threads = tf.train.start_queue_runners(coord=coord)

    # we grab an example from the CSV file.
    for iteration in range(1, 50):

        example, label = sess.run([features, Algo])
        print(example, label)

    coord.request_stop()
    coord.join(threads)

但我对如何存储我的数据以及如何使用它来生成带有不同标签的多类分类没有任何想法,因为我知道我的数据代表窗口的大小与时间的比较,因此它不会必须洗牌。

我不知道我是否清楚,但任何帮助都会非常好,谢谢!

0 个答案:

没有答案