1# Copyright 2017 The TensorFlow Authors. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================== 15"""Datasets for random number generators.""" 16import functools 17 18from tensorflow.python import tf2 19from tensorflow.python.data.ops import dataset_ops 20from tensorflow.python.util import deprecation 21from tensorflow.python.util.tf_export import tf_export 22 23 24@deprecation.deprecated(None, "Use `tf.data.Dataset.random(...)`.") 25@tf_export("data.experimental.RandomDataset", v1=[]) 26class RandomDatasetV2(dataset_ops.RandomDataset): 27 """A `Dataset` of pseudorandom values.""" 28 29 30@deprecation.deprecated(None, "Use `tf.data.Dataset.random(...)`.") 31@tf_export(v1=["data.experimental.RandomDataset"]) 32class RandomDatasetV1(dataset_ops.DatasetV1Adapter): 33 """A `Dataset` of pseudorandom values.""" 34 35 @functools.wraps(RandomDatasetV2.__init__) 36 def __init__(self, seed=None): 37 wrapped = RandomDatasetV2(seed) 38 super(RandomDatasetV1, self).__init__(wrapped) 39 40 41if tf2.enabled(): 42 RandomDataset = RandomDatasetV2 43else: 44 RandomDataset = RandomDatasetV1 45