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.""" 16from __future__ import absolute_import 17from __future__ import division 18from __future__ import print_function 19 20import functools 21 22from tensorflow.python import tf2 23from tensorflow.python.data.ops import dataset_ops 24from tensorflow.python.util import deprecation 25from tensorflow.python.util.tf_export import tf_export 26 27 28@deprecation.deprecated(None, "Use `tf.data.Dataset.random(...)`.") 29@tf_export("data.experimental.RandomDataset", v1=[]) 30class RandomDatasetV2(dataset_ops.RandomDataset): 31 """A `Dataset` of pseudorandom values.""" 32 33 34@deprecation.deprecated(None, "Use `tf.data.Dataset.random(...)`.") 35@tf_export(v1=["data.experimental.RandomDataset"]) 36class RandomDatasetV1(dataset_ops.DatasetV1Adapter): 37 """A `Dataset` of pseudorandom values.""" 38 39 @functools.wraps(RandomDatasetV2.__init__) 40 def __init__(self, seed=None): 41 wrapped = RandomDatasetV2(seed) 42 super(RandomDatasetV1, self).__init__(wrapped) 43 44 45if tf2.enabled(): 46 RandomDataset = RandomDatasetV2 47else: 48 RandomDataset = RandomDatasetV1 49