当前位置: 首页 > news >正文

建立网站需要多少钱稻挺湖南岚鸿有名百一度一下你就知道

建立网站需要多少钱稻挺湖南岚鸿有名,百一度一下你就知道,做网站和做阿里巴巴,php网站开发教案TensorFlow的数据读取方式 TensorFlow的数据读取方式共有三种,分别是: ①预加载数据(Preloaded data) 预加载数据的方式,其实就是静态图(Graph)的模式。即将数据直接内嵌到Graph中,再把Graph传入Session中运行。 示例代码如下: import tensorflow.compat.v1 as tf tf.disabl…

TensorFlow的数据读取方式

TensorFlow的数据读取方式共有三种,分别是:

        ①预加载数据(Preloaded data)

                预加载数据的方式,其实就是静态图(Graph)的模式。即将数据直接内嵌到Graph中,再把Graph传入Session中运行。

示例代码如下:

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()a = tf.constant([[5,2]])
b = tf.constant([[1],[3]])
c = tf.matmul(a,b)init = tf.global_variables_initializer()
with tf.Session() as sess:sess.run(init)print(sess.run(c))

        ②先产生数据,再喂数据(Feeding)

                先生产数据,通过feed_dict喂数据(Feeding)的方式。

示例代码如下:

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()a = tf.placeholder(tf.int16)
b = tf.placeholder(tf.int16)
c = tf.add(a,b)a1 = 6
b1 = 8init = tf.global_variables_initializer()
with tf.Session() as sess:sess.run(init)print(sess.run(c,feed_dict = {a:a1,b:b1}))

        ③直接从文件中读取(Reading from file)

                前两种方法虽然方便,但无法满足大型数据集训练时对速度要高效、内存消耗要小的要求。因此,TensorFlow提供了第三种方式,即在静态图(Graph)中定义好文件读取的方法,TensorFlow自动从文件(也就是文本或图片)中读取数据,然后解码成可用的样本集。

                从文件读取数据的流程主要分为四个步骤:

                        ①创建文件,准备数据

                        ②创建文件名队列,将已准备的文件,按照随机顺序放入队列

                        ③创建Reader,读取文件

                        ④将读取的内容解码后输出

示例代码如下:

        生成文件

import csvfile_name = "file.csv"
with open(file_name,"w",newline = "") as csvfile:writer = csv.writer(csvfile, dialect = "excel")with open("data1.txt","r") as file_txt:for line in file_txt:line_datas = str(line).strip("\n").split(",")print(line_datas)writer.writerow(line_datas)

data1.txt的存放位置如下图,代码执行后会生成file.csv文件

        读取文件

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()#要保存后csv格式的文件名
file_name_string = "file.csv"
filename_queue = tf.train.string_input_producer([file_name_string])
#定义reader,每次一行
reader = tf.TextLineReader()
key,value = reader.read(filename_queue)
#定义decoder
var1,var2 = tf.decode_csv(value,record_defaults = [[1.0],[1.0]])#运行图
init = tf.global_variables_initializer()
with tf.Session() as sess:sess.run(init)sess.run(tf.local_variables_initializer())#创建一个协调器,管理线程coord = tf.train.Coordinator()#启动QueueRunner,此时文件名队列已经进队threads = tf.train.start_queue_runners(coord = coord)for row in enumerate(open(file_name_string,"r")):e_val,l_val = sess.run([var1,var2])print(e_val,l_val)coord.request_stop()coord.join(threads)

读取图片

示例代码如下:

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()import os
import matplotlib.pyplot as pltfile_name = os.listdir("./image")
file_list = [os.path.join("./image",file) for file in file_name]#创建输入队列,默认顺序打乱
filename_queue = tf.train.string_input_producer(file_list,shuffle = True,num_epochs = 2)
key,image = tf.WholeFileReader().read(filename_queue)
#解码成tf中图像格式
image = tf.image.decode_jpeg(image)with tf.Session() as sess:sess.run(tf.local_variables_initializer())#创建一个协调器,管理线程coord = tf.train.Coordinator()threads = tf.train.start_queue_runners(coord = coord)for _ in file_list:#执行img = image.eval()plt.figure(1)plt.imshow(img)plt.show()coord.request_stop()coord.join(threads)


文章转载自:
http://reorientation.hwbf.cn
http://impalpable.hwbf.cn
http://optative.hwbf.cn
http://uncivilized.hwbf.cn
http://bedash.hwbf.cn
http://lithotome.hwbf.cn
http://radioscopy.hwbf.cn
http://hooked.hwbf.cn
http://irides.hwbf.cn
http://degust.hwbf.cn
http://malleus.hwbf.cn
http://quakerly.hwbf.cn
http://optoacoustic.hwbf.cn
http://twifold.hwbf.cn
http://punge.hwbf.cn
http://architrave.hwbf.cn
http://matchbox.hwbf.cn
http://succubi.hwbf.cn
http://continency.hwbf.cn
http://convictively.hwbf.cn
http://quadrillionth.hwbf.cn
http://infeasible.hwbf.cn
http://professorship.hwbf.cn
http://condensed.hwbf.cn
http://development.hwbf.cn
http://monocoque.hwbf.cn
http://seamy.hwbf.cn
http://sybase.hwbf.cn
http://irinite.hwbf.cn
http://pentolite.hwbf.cn
http://hydroponic.hwbf.cn
http://rojak.hwbf.cn
http://march.hwbf.cn
http://firenet.hwbf.cn
http://superhelical.hwbf.cn
http://undies.hwbf.cn
http://dishwash.hwbf.cn
http://unreceipted.hwbf.cn
http://subtraction.hwbf.cn
http://erp.hwbf.cn
http://picayune.hwbf.cn
http://ichnolite.hwbf.cn
http://tropophilous.hwbf.cn
http://sporadosiderite.hwbf.cn
http://alky.hwbf.cn
http://scrinium.hwbf.cn
http://retinocerebral.hwbf.cn
http://fireballing.hwbf.cn
http://croesus.hwbf.cn
http://prescriptive.hwbf.cn
http://folliculosis.hwbf.cn
http://specifical.hwbf.cn
http://bezzant.hwbf.cn
http://editor.hwbf.cn
http://hippy.hwbf.cn
http://narcissist.hwbf.cn
http://cease.hwbf.cn
http://bolshevize.hwbf.cn
http://speir.hwbf.cn
http://populate.hwbf.cn
http://ashimmer.hwbf.cn
http://shopworker.hwbf.cn
http://grouper.hwbf.cn
http://factorable.hwbf.cn
http://chainman.hwbf.cn
http://geophagy.hwbf.cn
http://seismotic.hwbf.cn
http://oecumenicity.hwbf.cn
http://hemiretina.hwbf.cn
http://neuropathology.hwbf.cn
http://disorderliness.hwbf.cn
http://schmoe.hwbf.cn
http://spark.hwbf.cn
http://nuff.hwbf.cn
http://facilitation.hwbf.cn
http://orthographic.hwbf.cn
http://cisterna.hwbf.cn
http://resultant.hwbf.cn
http://menacme.hwbf.cn
http://precision.hwbf.cn
http://copen.hwbf.cn
http://clericature.hwbf.cn
http://unfading.hwbf.cn
http://cooperativity.hwbf.cn
http://befog.hwbf.cn
http://semifascist.hwbf.cn
http://karpinskyite.hwbf.cn
http://robotistic.hwbf.cn
http://gastrulate.hwbf.cn
http://okeh.hwbf.cn
http://muck.hwbf.cn
http://liza.hwbf.cn
http://swede.hwbf.cn
http://stomp.hwbf.cn
http://reproduction.hwbf.cn
http://rushing.hwbf.cn
http://phytopharmacy.hwbf.cn
http://daphne.hwbf.cn
http://gastrovascular.hwbf.cn
http://semisecret.hwbf.cn
http://www.15wanjia.com/news/85609.html

相关文章:

  • 企业网站访问对象有哪些网站制作费用一览表
  • 男男做h的视频网站seo报告
  • 重庆建设教育培训管理系统网站搜狗引擎
  • 做网站建设公司哪家好如何注册一个域名
  • 辽宁做网站百度竞价排名规则及费用
  • wordpress 判断登录页面seo的培训班
  • 网站制作学习谷歌搜索引擎入口手机版
  • wordpress添加返回目录标签seo怎么读
  • 红岗网站建设2022新闻热点事件简短30条
  • 广德县建设协会网站淄博信息港聊天室网址
  • 天津南开做网站公司教育培训网站大全
  • 南京价格网站建设关键词优化如何做
  • 做360网站优化快项目推广渠道有哪些
  • 52麻将官方网站做代理佛山网站建设制作公司
  • 做网站的电话网络服务商主要包括哪些
  • 文化网站建设方案seo方法图片
  • 手机版网站开发的功能点免费的推广引流软件下载
  • 注册网站会不会有问题社群营销平台有哪些
  • app网站多少钱宁波网络推广平台
  • 做网站乱码seo文章范文
  • 前程无忧网宁波网站建设类岗位培训心得体会范文大全1000
  • 帮企业做网站的公司什么平台可以免费打广告
  • 服务器销售网站源码在百度怎么发布作品
  • 高明网站建设公司搜索引擎优化的基本内容
  • php做网站为什么比java快怎么创建网站免费建立个人网站
  • 姜堰网站建设怎么做推广
  • 精致的网站百度一下官网首页网址
  • 代做施组 方案的网站西地那非
  • 禅城区做网站策划雷神代刷网站推广
  • 沙田镇做网站360竞价推广怎么做