简体   繁体   English

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

[英]How can I use my own data with TensorFlow?

I have data set like this 我有这样的数据集

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 
....
....

This size is [n][20] and format of this file is CSV. 此大小为[n] [20],此文件的格式为CSV。 Also "n" is unknown. “n”也是未知的。 How can I import and use this data in with Tensorflow, in Python (Like: split train and test data). 如何在Python中使用Tensorflow导入和使用此数据(如:拆分列车和测试数据)。

I already looked https://www.tensorflow.org/versions/r0.11/how_tos/reading_data/index.html#reading-data . 我已经看过https://www.tensorflow.org/versions/r0.11/how_tos/reading_data/index.html#reading-data However, still I can't import this file in my code. 但是,我仍然无法在我的代码中导入此文件。

use the standard library module csv 使用标准库模块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

You can use pandas library. 你可以使用pandas库。

import pandas as pd
a=pd.read_csv('file.csv', header=None,index_col=0)
print a

and transform int to numpy array (if you want) with 并将int转换为numpy数组(如果需要)

a.values

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Tensorflow上使用带有我自己的数据的线性回归模型 - How to Use Linear Regression Model with My Own Data on Tensorflow 如何在TensorFlow中使用我自己的图像? - How do i use my own images in TensorFlow? 我如何在Tensorflow中准备自己的数据集(数千张图片)? - How i can prepare my own dataset (thousand of images) in Tensorflow? 如何使用张量流加载我自己的图像数据? - How to load my own Image data with tensorflow? 如何在Tensorflow中使用张量中的数据? - How can I use the data in a tensor in Tensorflow? 我正在尝试将 TensorFlow 与我自己的 csv 数据一起使用,但看到一个无害的“取消排队操作”警告 - I'm trying to use TensorFlow with my own csv data but seeing a harmless "Enqueue operation canceled" warning 如何使用我自己的数据在 PyTorch 上测试这个卷积神经网络? - How can I use my own data to test this Convolutional Neural Network on PyTorch? 如何在 TensorFlow 号码识别中使用自己的手绘图像 - How do I use my own Hand-Drawn Image in TensorFlow Number Recognition 在colaboratory中导入我自己的模块后,我该如何使用它? - After import my own module in colaboratory, how can i use it? 如何使用 tensorflow model 预测我自己的图像 - How to use tensorflow model for predicting my own images
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM