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表示 ...
随机推荐
- Linux用户及文件权限管理
Linux用户及文件权限管理
- ThinkPHP框架 基础 链接数据库
在第一次成功访问应用入口文件的时候,会显示出一个系统默认的欢迎页面并自动在APPLication文件夹里生成三个文件夹,如下,第一次访问应用文件路径:localhost/tr/index.php ...
- hdu5157 Harry and magic string【manacher】
Harry and magic string Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- CodeForces 1099F - Cookies - [DFS+博弈+线段树]
题目链接:https://codeforces.com/problemset/problem/1099/F Mitya and Vasya are playing an interesting gam ...
- tensorRT使用python进行网络定义
- 新装的arcgis10.5特别卡
在之前装过arcgis10.5,用了一段时间感觉还不错. 由于二次开发要用到AO,当时缺少开发包,所以用了10.4. 现在跟师傅合作开发,要跟他保持一致,所以用了arcgis10.5. 但是装的 ...
- page 页 分页 分段
小结: 1. 页:磁盘和内存间传输数据的最小单位: MySQL: What is a page? https://stackoverflow.com/questions/4401910/mysql-w ...
- JNI 入门
1.http://cherishlc.iteye.com/blog/1756762 Android 学习笔记--利用JNI技术在Android中调用.调试C++代码 2.http://my.eoe.c ...
- 将获得datebox值的文本形式转为日期格式
在使用datebox时,已选择结束日期后,再次选择开始日期.此时判断开始日期不能大于结束日期. datebox的onSelect: function (date){}事件传入的参数是日期类型,而使用d ...
- LeetCode 976 Largest Perimeter Triangle 解题报告
题目要求 Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero ...