[英]Reading data from .csv or .txt in python
我是python和TensorFlow的初學者。 按照TensorFlow網站上的“讀取數據”的說明,我想將一些數據加載到python中的項目中。 那是我的代碼,非常簡單
import tensorflow as tf
files = tf.train.match_filenames_once("*.txt")
print(files)
結果是
Tensor("matching_filenames/read:0", dtype=string)
我已將要讀取的數據放入該項目的工作空間。 為什么仍然告訴我匹配的文件名為0?
另外,我要讀取的數據是一維數據列表,每行兩次。 文件大小約為100W以上。
我正在使用的IDE是pycharm
謝謝!
您的變量Files
是一個Tensor(TensorFlow圖中的一個節點)。 您需要在TensorFlow會話中運行它,以便訪問其值。
files = tf.train.match_filenames_once("*.txt")
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print(sess.run(files))
我建議您閱讀官方文檔,以進一步了解TensorFlow,Tensor和TensorFlow圖。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.