日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

tensorflow随笔-读文件

發(fā)布時間:2025/3/12 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 tensorflow随笔-读文件 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Sat Sep 15 10:54:53 2018@author: liuxing讀取文件 """ import tensorflow as tf import osg=tf.Graph() with g.as_default():#生成文件名隊列fileName=os.getcwd()+"/diabetes.csv"fileNameQueue=tf.train.string_input_producer([fileName])#生成記錄鍵值對reader=tf.TextLineReader(skip_header_lines=1)key,value=reader.read(fileNameQueue)with tf.Session(graph=g) as sess:# 開始產(chǎn)生文件名隊列coord = tf.train.Coordinator()threads = tf.train.start_queue_runners(coord=coord)print "key:"print sess.run(key)#文件名print "values:"print sess.run(value)#讀取一行的內(nèi)容coord.request_stop()coord.join(threads)

key:
/Users/xxxxx/Documents/AIstudy/tf/diabetes.csv:2
values:
1,85,66,29,0,26.6,0.351,31,0

#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Sat Sep 15 10:54:53 2018@author: liuxing讀取文件 Pregnancies,Glucose,BloodPressure,SkinThickness,Insulin,BMI,DiabetesPedigreeFunction,Age,Outcome """ import tensorflow as tf import osg=tf.Graph() with g.as_default():#生成文件名隊列fileName=os.getcwd()+"/1.csv"fileNameQueue=tf.train.string_input_producer([fileName])#生成記錄鍵值對reader=tf.TextLineReader(skip_header_lines=1)key,value=reader.read(fileNameQueue)recordDefaults=[[1.],[1.],[1.],[1.],[1.],[1.],[1.],[1.],[1.]]decoded=tf.decode_csv(value,record_defaults=recordDefaults)pregnancies,glucose,bloodPressure,skinThickness,insulin,bmi,diabetespedigreefunction,age,outcome=tf.train.shuffle_batch(decoded,batch_size=2,capacity=1000,min_after_dequeue=1) features=tf.transpose(tf.stack([pregnancies,glucose,bloodPressure,skinThickness,insulin,bmi,diabetespedigreefunction,age,outcome]))with tf.Session(graph=g) as sess:# 開始產(chǎn)生文件名隊列coord = tf.train.Coordinator()threads = tf.train.start_queue_runners(coord=coord)print "鍵:"print sess.run(key)#文件名print "值:"print sess.run(value)#讀取一行的內(nèi)容print "屬性:"print sess.run(features) coord.request_stop()coord.join(threads)

鍵:
/Users/xxx/Documents/AIstudy/tf/1.csv:2
值:
1,89,66,23,94,28.1,0.167,21,0
屬性:
[[ 1. 89. 66. … 0.167 21. 0. ]
[ 6. 148. 72. … 0.627 50. 1. ]]

1.csv

Pregnancies,Glucose,BloodPressure,SkinThickness,Insulin,BMI,DiabetesPedigreeFunction,Age,Outcome
6,148,72,35,0,33.6,0.627,50,1
1,85,66,29,0,26.6,0.351,31,0
8,183,64,0,0,23.3,0.672,32,1
1,89,66,23,94,28.1,0.167,21,0

總結(jié)

以上是生活随笔為你收集整理的tensorflow随笔-读文件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。