TensorFlow读取CSV数据
代码来源于官方文档,做了一些小小的调整:
# -*- 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)
file01.csv 和 file02.csv 格式一样:
19,3,1
10,2,3
11,3,1
12,4,2
17,5,1
18,6,2
......
TensorFlow读取CSV数据的更多相关文章
- TensorFlow读取CSV数据(批量)
直接上代码: # -*- coding:utf-8 -*- import tensorflow as tf def read_data(file_queue): reader = tf.TextLin ...
- Java读取CSV数据并写入txt文件
读取CSV数据并写入txt文件 package com.vfsd; import java.io.BufferedWriter; import java.io.File; import java.io ...
- java 读取CSV数据并写入txt文本
java 读取CSV数据并写入txt文本 package com.vfsd; import java.io.BufferedWriter; import java.io.File; import ja ...
- tensorflow读取训练数据方法
1. 预加载数据 Preloaded data # coding: utf-8 import tensorflow as tf # 设计Graph x1 = tf.constant([2, 3, 4] ...
- PHP读取CSV数据写入数据库
/*读取csv文件*/ public function testCsv(){ $fileName = "tel.csv"; $fp=fopen($fileName,"r& ...
- Tensorflow读取csv文件(转)
常用的直接读取方法实例:#加载包 import tensorflow as tf import os #设置工作目录 os.chdir("你自己的目录") #查看目录 print( ...
- pandas读取csv数据时设置index
比如读取数据时想把第一列设为index,那么只需要简单的 pd.read_csv("new_wordvecter.csv",index_col=[0]) 这里index_col可以 ...
- python 读取csv 数据并画图分析
数据源 : https://pan.baidu.com/s/1eR593Uy 密码: yqjh python环境 python3 #encoding: utf-8 import csv impo ...
- matlab读取csv文件数据并绘图
circle.m(画二维圆的函数) %该函数是画二维圆圈,输入圆心坐标和半径%rectangle()函数参数‘linewidth’修饰曲线的宽度%'edgecolor','r',edgecolor表示 ...
随机推荐
- MySQL多实例部署与优化
MySQL安装 ##上传MySQL安装包## mkdir /home/oldboy/tools -p cd /home/oldboy/tools/ ###wget -q http://mirrors. ...
- python数据类型之字典(二)
字典的基本操作 键值查找: >>> aInfo = {'Wangdachui':3000,'Niuyun':2000,'Linling':4500,'Tianqi':8000} &g ...
- 泡泡一分钟:Exploiting Points and Lines in Regression Forests for RGB-D Camera Relocalization
Exploiting Points and Lines in Regression Forests for RGB-D Camera Relocalization 利用回归森林中的点和线进行RGB-D ...
- {python之协程}一 引子 二 协程介绍 三 Greenlet 四 Gevent介绍 五 Gevent之同步与异步 六 Gevent之应用举例一 七 Gevent之应用举例二
python之协程 阅读目录 一 引子 二 协程介绍 三 Greenlet 四 Gevent介绍 五 Gevent之同步与异步 六 Gevent之应用举例一 七 Gevent之应用举例二 一 引子 本 ...
- ubuntu下c/c++/python/go编译运行
C语言: .c文件 编译器gcc//my_code下hello.c文件 $sudo apt install gcc $gcc hello.c -o hello $./hello C++: .cpp文件 ...
- 安装arcgis10.5不能启动服务的解决方案
最近由于公司需要,要装arcgis10.5,但是装这软件就费了好久的功夫.以前用的10.2,安装比较简单,但是10.5看起来就不一样了,下载完成后就会发现多了一个破解文件.按照教程一步一步安装的,但是 ...
- 【Linux】Linux 常用命令汇总
查看软件xxx安装内容:dpkg -L xxx 查找软件库中的软件:apt-cache search 正则表达式 查找软件库中的软件:aptitude search 软件包 查找文件属于哪个包:dpk ...
- 转:JAVAWEB开发之权限管理(二)——shiro入门详解以及使用方法、shiro认证与shiro授权
原文地址:JAVAWEB开发之权限管理(二)——shiro入门详解以及使用方法.shiro认证与shiro授权 以下是部分内容,具体见原文. shiro介绍 什么是shiro shiro是Apache ...
- 洛谷P4426 毒瘤 [HNOI/AHOI2018] 虚树+树上dp
正解:虚树+树上dp 解题报告: 传送门! 首先解释一下题意趴,,,语文70pts选手已经开始看不懂题辣QAQ 大概就是个给一个图,求独立集方案,且保证图是联通的,边的数量最多只比点多10 首先思考如 ...
- 洛谷P1315 观光公交 [noip2011D2T3] 贪心
正解:贪心 解题报告: 这里是链接! 唔我觉得还是很容易想到是贪心的,这个难就难在怎么贪心 下面列一下常见的几个贪心思想: 1)根据车上的人数排序,人最多的那条路用加速器 错误,人数多并不意味着加速的 ...