xingnie

import numpy as np
import tensorflow as tf
np.random.seed(0)
x = np.random.sample((11,2))
# make a dataset from a numpy array
print(x)

dataset = tf.data.Dataset.from_tensor_slices(x)
dataset = dataset.shuffle(2) # 将数据打乱,数值越大,混乱程度越大
dataset = dataset.batch(4) # 按照顺序取出4行数据,最后一次输出可能小于batch
dataset = dataset.repeat() # 数据集重复了指定次数
# repeat()在batch操作输出完毕后再执行,若在之前,相当于先把整个数据集复制两次
#为了配合输出次数,一般默认repeat()空

# create the iterator
iter = dataset.make_one_shot_iterator()
el = iter.get_next()

with tf.Session() as sess:
for i in range(6):
value = sess.run(el)
print(value)

 

 

更多的不同和进阶可以参考这个博客

 https://blog.csdn.net/qq_16234613/article/details/81703228

分类:

技术点:

相关文章:

  • 2022-03-13
  • 2021-09-17
  • 2022-12-23
  • 2021-12-24
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-13
  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
  • 2022-03-01
  • 2021-12-07
  • 2022-12-23
相关资源
相似解决方案