代码来源于官方文档,做了一些小小的调整:

# -*- 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数据的更多相关文章

  1. TensorFlow读取CSV数据(批量)

    直接上代码: # -*- coding:utf-8 -*- import tensorflow as tf def read_data(file_queue): reader = tf.TextLin ...

  2. Java读取CSV数据并写入txt文件

    读取CSV数据并写入txt文件 package com.vfsd; import java.io.BufferedWriter; import java.io.File; import java.io ...

  3. java 读取CSV数据并写入txt文本

    java 读取CSV数据并写入txt文本 package com.vfsd; import java.io.BufferedWriter; import java.io.File; import ja ...

  4. tensorflow读取训练数据方法

    1. 预加载数据 Preloaded data # coding: utf-8 import tensorflow as tf # 设计Graph x1 = tf.constant([2, 3, 4] ...

  5. PHP读取CSV数据写入数据库

    /*读取csv文件*/ public function testCsv(){ $fileName = "tel.csv"; $fp=fopen($fileName,"r& ...

  6. Tensorflow读取csv文件(转)

    常用的直接读取方法实例:#加载包 import tensorflow as tf import os #设置工作目录 os.chdir("你自己的目录") #查看目录 print( ...

  7. pandas读取csv数据时设置index

    比如读取数据时想把第一列设为index,那么只需要简单的 pd.read_csv("new_wordvecter.csv",index_col=[0]) 这里index_col可以 ...

  8. python 读取csv 数据并画图分析

    数据源 : https://pan.baidu.com/s/1eR593Uy    密码: yqjh python环境 python3 #encoding: utf-8 import csv impo ...

  9. matlab读取csv文件数据并绘图

    circle.m(画二维圆的函数) %该函数是画二维圆圈,输入圆心坐标和半径%rectangle()函数参数‘linewidth’修饰曲线的宽度%'edgecolor','r',edgecolor表示 ...

随机推荐

  1. 在windows下搭建vueJS开发环境

    转自:https://www.cnblogs.com/RexSheng/p/6934413.html nodejs官网http://nodejs.cn/下载安装包,无特殊要求可本地傻瓜式安装,这里选择 ...

  2. C#5种方式生成缩略图

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  3. [No0000149]ReSharper操作指南6/16-编码协助之其他协助

    语法高亮 ReSharper扩展了默认Visual Studio的符号高亮显示.此外,它还会使用可配置的颜色突出显示字段,局部变量,类型和其他标识符.例如,ReSharper语法突出显示允许您轻松区分 ...

  4. [No000011D].NETCORE1/19-.NET Core 指南

    .NET Core 是一个通用开发平台,由 Microsoft 和 GitHub 上的 .NET 社区共同维护.跨平台的,支持 Windows.macOS 和 Linux,并且可用于设备.云和嵌入式/ ...

  5. vsftpd上传文件出现553 Could not create file错误解决方法

    1.确定目录权限 2.关闭selinux

  6. 内联扩展 inline expansion

    让编译器直接将完整的函数体插入到每一个调用该函数的地方,从而提高函数调用的运行速度. 优秀的JIT编译器会通过侦测运行信息,仅将需要频繁运行的瓶颈部分进行编译,从而大大削减编译所需的时间. 而且,利用 ...

  7. Spring Boot引起的“堆外内存泄漏”排查及经验总结

    小结: 检索词:C++内存分配器.jvm内存模型.gdb.内存泄露 https://tech.meituan.com/2019/01/03/spring-boot-native-memory-leak ...

  8. 如果是多个 c 代码的源码文件,编译方法如下: $ gcc test1.c test2.c -o main.out $ ./main.out test1.c 与 test2.c 是两个源代码文件。

    如果是多个 c 代码的源码文件,编译方法如下: $ gcc test1.c test2.c -o main.out $ ./main.out test1.c 与 test2.c 是两个源代码文件.

  9. 在U盘上安装GRUB2直接引导ISO

    本文的内容来源于 http://maxmars.net/blog/2012/10/02/boot-multiple-iso-from-usb-using-linux/ 以下所有命令都在 root 用户 ...

  10. mysql存储过程游标嵌套循环

    自己写的一个mysql存储过程如下: BEGIN DECLARE _did bigint(20);DECLARE _count int;DECLARE s1 int;DECLARE cur_1 CUR ...