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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

tensorflow dataset_ops shuffle()方法 (随机重新排列此数据集的元素)

發布時間:2025/3/20 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 tensorflow dataset_ops shuffle()方法 (随机重新排列此数据集的元素) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
def shuffle(self, buffer_size, seed=None, reshuffle_each_iteration=None):"""Randomly shuffles the elements of this dataset.隨機重新排列此數據集的元素。Args:buffer_size: A `tf.int64` scalar `tf.Tensor`, representing thenumber of elements from this dataset from which the newdataset will sample.tf.int64標量tf.Tensor,表示此數據集中要從中采樣新數據集的元素數。seed: (Optional.) A `tf.int64` scalar `tf.Tensor`, representing therandom seed that will be used to create the distribution. See`tf.set_random_seed` for behavior.tf.int64標量tf.Tensor,表示將用于創建分布的隨機種子。 有關行為,請參見“ tf.set_random_seed”。reshuffle_each_iteration: (Optional.) A boolean, which if true indicatesthat the dataset should be pseudorandomly reshuffled each time it isiterated over. (Defaults to `True`.)布爾值,如果為true,則表示每次迭代數據集時都應偽隨機地重排。 (默認為“ True”。)Returns:Dataset: A `Dataset`. 數據集:一個“數據集”。"""return ShuffleDataset(self, buffer_size, seed, reshuffle_each_iteration) # -*- coding: utf-8 -*- """ @File : 191208_test_Eager_execution_once_cls.py @Time : 2019/12/8 12:25 @Author : Dontla @Email : sxana@qq.com @Software: PyCharm """import tensorflow as tftf.enable_eager_execution()ds_tensors = tf.data.Dataset.from_tensor_slices([1, 2, 3, 4, 5, 6])print(type(ds_tensors)) # <class 'tensorflow.python.data.ops.dataset_ops.TensorSliceDataset'> print(type(ds_tensors.map(tf.square))) # <class 'tensorflow.python.data.ops.dataset_ops.MapDataset'> print(type(ds_tensors.map(tf.square).shuffle(2))) # <class 'tensorflow.python.data.ops.dataset_ops.ShuffleDataset'> print(type(ds_tensors.map(tf.square).shuffle(2).batch(2))) # <class 'tensorflow.python.data.ops.dataset_ops.BatchDataset'>

總結

以上是生活随笔為你收集整理的tensorflow dataset_ops shuffle()方法 (随机重新排列此数据集的元素)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。