python - 如何在 TensorFlow 中使用我自己的数据?

标签 python tensorflow

我有这样的数据集

2016-10-24,23.00,15.47,76.00,1015.40,0.00,0.00,100.00,26.00,100.00,100.00,0.00,6.88,186.01,12.26,220.24,27.60,262.50,14.04,2.1
2016-10-24,22.00,16.14,73.00,1014.70,0.00,0.00,10.20,34.00,0.00,2.00,0.00,6.49,176.82,11.97,201.16,24.27,249.15,7.92,0.669999 
....
....

此文件大小为 [n][20],文件格式为 CSV。 “n”也是未知的。如何在 Python 中通过 Tensorflow 导入和使用这些数据(例如:分割训练数据和测试数据)。

我已经看过了https://www.tensorflow.org/versions/r0.11/how_tos/reading_data/index.html#reading-data 。但是,我仍然无法在代码中导入此文件。

最佳答案

使用标准库模块csv

import csv
with open('yourfile.csv', newline='') as f:
   r = csv.reader(f)
   for row in r:
       print(row) #Each row is a list of the values in a line of your file
                  #All you have to do then is process them in tensorflow

关于python - 如何在 TensorFlow 中使用我自己的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40361001/

相关文章:

tensorflow - 有什么方法可以使用tensorflow-federated API对真实的多台机器进行联邦学习吗?

python - tensorflow 逐元素乘法广播?

python - matplotlib如何用定义的颜色绘制多条线?

python - 在 python 中编写一个快速解析器

tensorflow - 可视化神经网络层激活

python - Tensorflow 中的 2D bool 掩码

python - 尝试理解 model.predict 的输出

python - 如何通过列中的重复值自动递增计数器

python - 使用 matplotlib 制作动画,其中点被动态添加到图形中

Python 和 OpenCV : Second largest object