tensorflow能导入.mat数据吗

如题所述

第1个回答  2017-09-14
完全可以, 我用过的。Python自带功能
scipy.io.loadmat() 可以得到np
第2个回答  2017-09-14
参考代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

# -*- coding:utf-8 -*-
import tensorflow as tf

filename_queue = tf.train.string_input_producer(["file01.csv", "file02.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]]
col1, col2, col3 = tf.decode_csv(value, record_defaults = record_defaults)
features = tf.stack([col1, col2])

init_op = tf.global_variables_initializer()
local_init_op = tf.local_variables_initializer() # local variables like epoch_num, batch_size 可以不初始化local
with tf.Session() as sess:
sess.run(init_op)
sess.run(local_init_op)

# Start populating the filename queue.
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)

for i in range(5):
# Retrieve a single instance:
example, label = sess.run([features, col3])
print(example)
print(label)

coord.request_stop()
coord.join(threads)
相似回答