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

汉口做网站jw100百度导航2023年最新版

汉口做网站jw100,百度导航2023年最新版,用模板做网站会被盗吗,团购网站怎么运营目录 前言示例示例1示例2示例3示例4 前言 TensorFlow 的 tf.data.Dataset API 提供了一种灵活且高效的方式来加载和预处理数据。它可以轻松处理大规模数据集,并支持多种数据源格式。 所有数据集相关的内容都在tf.data中,from_tensor_slices:…

目录

  • 前言
  • 示例
    • 示例1
    • 示例2
    • 示例3
    • 示例4

前言

TensorFlow 的 tf.data.Dataset API 提供了一种灵活且高效的方式来加载和预处理数据。它可以轻松处理大规模数据集,并支持多种数据源格式。 所有数据集相关的内容都在tf.data中,from_tensor_slices:可以从元组, 列表, 字典, ndarray中创建dataset。

示例

示例1

import tensorflow as tf
import numpy as npdataset = tf.data.Dataset.from_tensor_slices(np.arange(10))  
print (dataset)# 数据集最基础的用法就是取数据
for item in dataset:print(item)

结果如下:

<TensorSliceDataset shapes: (), types: tf.int32>
tf.Tensor(0, shape=(), dtype=int32)
tf.Tensor(1, shape=(), dtype=int32)
tf.Tensor(2, shape=(), dtype=int32)
tf.Tensor(3, shape=(), dtype=int32)
tf.Tensor(4, shape=(), dtype=int32)
tf.Tensor(5, shape=(), dtype=int32)
tf.Tensor(6, shape=(), dtype=int32)
tf.Tensor(7, shape=(), dtype=int32)
tf.Tensor(8, shape=(), dtype=int32)
tf.Tensor(9, shape=(), dtype=int32)

示例2

import tensorflow as tf
import numpy as np# 从元组创建dataset, (x,y)
x = np.array([[1, 2], [3, 4], [5, 6]])
y = np.array(['cat', 'dog', 'fox'])
dataset = tf.data.Dataset.from_tensor_slices((x, y))
for item_x, item_y in dataset:print(item_x.numpy(), item_y.numpy().decode())

结果如下

[1 2] b'cat'
[3 4] b'dog'
[5 6] b'fox'

示例3

import tensorflow as tf
import numpy as np# 从元组创建dataset, (x,y)
x = np.array([[1, 2], [3, 4], [5, 6]])
y = np.array(['cat', 'dog', 'fox'])
dataset = tf.data.Dataset.from_tensor_slices({'feature': x,'label': y
})
for item in dataset:print(item['feature'].numpy(), item['label'].numpy())

结果如下

[1 2] b'cat'
[3 4] b'dog'
[5 6] b'fox'

示例4

import tensorflow as tf
import numpy as np# interleave
# 最常见用法 : 文件名dataset  --> 具体数据集
dataset = tf.data.Dataset.from_tensor_slices(np.arange(10))
dataset = dataset.repeat(3).batch(7)
# map_fn, cycle_length 并行长度, block_length 
dataset = dataset.interleave(lambda v: tf.data.Dataset.from_tensor_slices(v),cycle_length = 5,block_length = 5
)
for item in dataset:print(item)

结果如下

tf.Tensor(0, shape=(), dtype=int32)
tf.Tensor(1, shape=(), dtype=int32)
tf.Tensor(2, shape=(), dtype=int32)
tf.Tensor(3, shape=(), dtype=int32)
tf.Tensor(4, shape=(), dtype=int32)
tf.Tensor(7, shape=(), dtype=int32)
tf.Tensor(8, shape=(), dtype=int32)
tf.Tensor(9, shape=(), dtype=int32)
tf.Tensor(0, shape=(), dtype=int32)
tf.Tensor(1, shape=(), dtype=int32)
tf.Tensor(4, shape=(), dtype=int32)
tf.Tensor(5, shape=(), dtype=int32)
tf.Tensor(6, shape=(), dtype=int32)
tf.Tensor(7, shape=(), dtype=int32)
tf.Tensor(8, shape=(), dtype=int32)
tf.Tensor(1, shape=(), dtype=int32)
tf.Tensor(2, shape=(), dtype=int32)
tf.Tensor(3, shape=(), dtype=int32)
tf.Tensor(4, shape=(), dtype=int32)
tf.Tensor(5, shape=(), dtype=int32)
tf.Tensor(8, shape=(), dtype=int32)
tf.Tensor(9, shape=(), dtype=int32)
tf.Tensor(5, shape=(), dtype=int32)
tf.Tensor(6, shape=(), dtype=int32)
tf.Tensor(2, shape=(), dtype=int32)
tf.Tensor(3, shape=(), dtype=int32)
tf.Tensor(9, shape=(), dtype=int32)
tf.Tensor(0, shape=(), dtype=int32)
tf.Tensor(6, shape=(), dtype=int32)
tf.Tensor(7, shape=(), dtype=int32)
http://www.dtcms.com/wzjs/109386.html

相关文章:

  • 2013网站建设方案优化网站搜索排名
  • 查钓鱼网站google seo怎么优化
  • 专业网站建设怎么样搜索引擎优化策略
  • 江门网站制作建设在线网络培训平台
  • 做一份seo网站诊断昆山网站建设
  • 设计师平台网站优秀营销案例分享
  • 长春疫情刚刚最新消息今天seo中心
  • php做电子商务网站的种类信阳seo优化
  • 网站建设 业务员提成长沙网站托管优化
  • 古镇网站建设站长seo综合查询工具
  • 网站建设网站模版一站式营销推广
  • ui设计公司网站亚马逊关键词
  • 盐城网站建设要多少钱做网页
  • 佛山建设网站制作全球搜效果怎么样
  • 做海购的网站免费网站电视剧全免费
  • 哪个网站做外贸好如何做个人网站
  • 锦州网页制作厦门关键词排名优化
  • 在阿里巴巴上做网站需要什么百度客服中心电话
  • 硬笔书法网站是谁做的搜狗网址
  • 龙岩天宫山缆车门票多少钱关键词优化排名软件s
  • 网站建设与网页设计开题报告seo搜索引擎优化培训班
  • 老房装修改造哪家好学seo哪个培训好
  • 吉林省建设厅网站查询郑州网络营销与网站推广
  • 做培训的网站建设广州 竞价托管
  • 深圳 经营性网站备案上海seo网站策划
  • 电子商务网站建设指导思想中国网站排名100
  • 档案信息网站建设的意义长沙快速排名优化
  • 新手练习做网站哪个网站比较合适专业网站优化推广
  • 广州网站制作多少钱东莞疫情最新消息今天又封了
  • 万网域名优惠口令seo一个关键词多少钱