MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / _DataSet

Class _DataSet

neural_network/input_data.py:114–243  ·  view source on GitHub ↗

Container class for a _DataSet (deprecated). THIS CLASS IS DEPRECATED.

Source from the content-addressed store, hash-verified

112
113
114class _DataSet:
115 """Container class for a _DataSet (deprecated).
116
117 THIS CLASS IS DEPRECATED.
118 """
119
120 @deprecated(
121 None,
122 "Please use alternatives such as official/mnist/_DataSet.py"
123 " from tensorflow/models.",
124 )
125 def __init__(
126 self,
127 images,
128 labels,
129 fake_data=False,
130 one_hot=False,
131 dtype=dtypes.float32,
132 reshape=True,
133 seed=None,
134 ):
135 """Construct a _DataSet.
136
137 one_hot arg is used only if fake_data is true. `dtype` can be either
138 `uint8` to leave the input as `[0, 255]`, or `float32` to rescale into
139 `[0, 1]`. Seed arg provides for convenient deterministic testing.
140
141 Args:
142 images: The images
143 labels: The labels
144 fake_data: Ignore inages and labels, use fake data.
145 one_hot: Bool, return the labels as one hot vectors (if True) or ints (if
146 False).
147 dtype: Output image dtype. One of [uint8, float32]. `uint8` output has
148 range [0,255]. float32 output has range [0,1].
149 reshape: Bool. If True returned images are returned flattened to vectors.
150 seed: The random seed to use.
151 """
152 seed1, seed2 = random_seed.get_seed(seed)
153 # If op level seed is not set, use whatever graph level seed is returned
154 self._rng = np.random.default_rng(seed1 if seed is None else seed2)
155 dtype = dtypes.as_dtype(dtype).base_dtype
156 if dtype not in (dtypes.uint8, dtypes.float32):
157 msg = f"Invalid image dtype {dtype!r}, expected uint8 or float32"
158 raise TypeError(msg)
159 if fake_data:
160 self._num_examples = 10000
161 self.one_hot = one_hot
162 else:
163 assert images.shape[0] == labels.shape[0], (
164 f"images.shape: {images.shape} labels.shape: {labels.shape}"
165 )
166 self._num_examples = images.shape[0]
167
168 # Convert shape from [num examples, rows, columns, depth]
169 # to [num examples, rows*columns] (assuming depth == 1)
170 if reshape:
171 assert images.shape[3] == 1

Callers 2

fakeFunction · 0.85
read_data_setsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected