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表示 ...
随机推荐
- ThinkPHP框架 做个简单表单 添加数据例子__ACTION__ __SELF__
public function zhuCe(){//自定义zhuCe方法和zhuCe显示表里的__ACTiON__这个相互交接 //实现两个逻辑 //1,显示注册页面 //2.向数据库添加内容 //自 ...
- VUE----整理
-------------------------------------------------------------------VUE------------------------------ ...
- ie9 form submit 请求参数问题替代办法
//隐藏表单 <input id="hdPeriod" name="period" type="hidden" value=" ...
- .NET Core开发日志——Entity Framework与PostgreSQL
Entity Framework在.NET Core中被命名为Entity Framework Core.虽然一般会用于对SQL Server数据库进行数据操作,但其实它还支持其它数据库,这里就以Po ...
- .NET Core开发日志——视图与页面
当一个Action完成它的任务后,通常需要返回一个实现IActionResult的对象,而最常见的就是View或者ViewResult,所谓的视图对象.那么视图与最终所看到的页面之间的联系又是怎样形成 ...
- 访问Google的办法
访问Google的办法 http://www.liu16.com/g.html http://ac.scmor.com/ https://www.elastic.co/guide/en/elastic ...
- iOS中UITableView的一些问题思考
UITableview的数据源为什么是代理,而不是引用? 我的理解,一般情况下控制器会引用tableView, 数据源和代理方法都是tableView的一个若引用,出了“tableView.datas ...
- char是所有类型中最短的 char多为8位,
https://en.wikipedia.org/wiki/C_data_typesIn practice, char is usually eight bits in size and short ...
- 单KEY业务,数据库水平切分架构实践 | 架构师之路
https://mp.weixin.qq.com/s/8aI9jS0SXJl5NdcM3TPYuQ 单KEY业务,数据库水平切分架构实践 | 架构师之路 原创: 58沈剑 架构师之路 2017-06- ...
- [network] netfilter
netfilter 是什么? netfilter.org is home to the software of the packet filtering framework inside the Li ...