2323import org .tensorflow .framework .data .impl .TakeDataset ;
2424import org .tensorflow .framework .data .impl .TensorSliceDataset ;
2525import org .tensorflow .framework .data .impl .TextLineDataset ;
26+ import org .tensorflow .ndarray .Shape ;
2627import org .tensorflow .op .Op ;
2728import org .tensorflow .op .Ops ;
28- import org .tensorflow .ndarray . Shape ;
29+ import org .tensorflow .types . family . TType ;
2930
3031import java .util .ArrayList ;
3132import java .util .Arrays ;
3233import java .util .Iterator ;
3334import java .util .List ;
3435import java .util .function .Function ;
35- import org .tensorflow .types .family .TType ;
3636
3737/**
3838 * Represents a potentially large list of independent elements (samples), and allows iteration and
@@ -44,8 +44,19 @@ public abstract class Dataset implements Iterable<List<Operand<?>>> {
4444 private List <Class <? extends TType >> outputTypes ;
4545 private List <Shape > outputShapes ;
4646
47+ /**
48+ * Creates a Dataset
49+ *
50+ * @param tf the TensorFlow Ops
51+ * @param variant the tensor that represents the dataset.
52+ * @param outputTypes a list of output types produced by this data set.
53+ * @param outputShapes a list of output shapes produced by this data set.
54+ */
4755 public Dataset (
48- Ops tf , Operand <?> variant , List <Class <? extends TType >> outputTypes , List <Shape > outputShapes ) {
56+ Ops tf ,
57+ Operand <?> variant ,
58+ List <Class <? extends TType >> outputTypes ,
59+ List <Shape > outputShapes ) {
4960 if (tf == null ) {
5061 throw new IllegalArgumentException ("Ops accessor cannot be null." );
5162 }
@@ -61,6 +72,11 @@ public Dataset(
6172 this .outputShapes = outputShapes ;
6273 }
6374
75+ /**
76+ * Creates a Dataset that is a copy of another Dataset
77+ *
78+ * @param other the other Dataset
79+ */
6480 protected Dataset (Dataset other ) {
6581 this .tf = other .tf ;
6682 this .variant = other .variant ;
@@ -127,11 +143,12 @@ public final Dataset take(long count) {
127143 * Returns a new Dataset which maps a function across all elements from this dataset, on a single
128144 * component of each element.
129145 *
130- * <p>For example, suppose each element is a {@code List<Operand<?>>} with 2 components: (features,
131- * labels).
146+ * <p>For example, suppose each element is a {@code List<Operand<?>>} with 2 components:
147+ * (features, labels).
132148 *
133- * <p>Calling {@code dataset.mapOneComponent(0, features -> tf.math.mul(features, tf.constant(2)))} will
134- * map the function over the `features` component of each element, multiplying each by 2.
149+ * <p>Calling {@code dataset.mapOneComponent(0, features -> tf.math.mul(features,
150+ * tf.constant(2)))} will map the function over the `features` component of each element,
151+ * multiplying each by 2.
135152 *
136153 * @param index The index of the component to transform.
137154 * @param mapper The function to apply to the target component.
@@ -150,8 +167,8 @@ public Dataset mapOneComponent(int index, Function<Operand<?>, Operand<?>> mappe
150167 * Returns a new Dataset which maps a function across all elements from this dataset, on all
151168 * components of each element.
152169 *
153- * <p>For example, suppose each element is a {@code List<Operand<?>>} with 2 components: (features,
154- * labels).
170+ * <p>For example, suppose each element is a {@code List<Operand<?>>} with 2 components:
171+ * (features, labels).
155172 *
156173 * <p>Calling {@code dataset.mapAllComponents(component -> tf.math.mul(component,
157174 * tf.constant(2)))} will map the function over the both the `features` and `labels` components of
@@ -172,8 +189,8 @@ public Dataset mapAllComponents(Function<Operand<?>, Operand<?>> mapper) {
172189 /**
173190 * Returns a new Dataset which maps a function over all elements returned by this dataset.
174191 *
175- * <p>For example, suppose each element is a {@code List<Operand<?>>} with 2 components: (features,
176- * labels).
192+ * <p>For example, suppose each element is a {@code List<Operand<?>>} with 2 components:
193+ * (features, labels).
177194 *
178195 * <p>Calling
179196 *
@@ -261,46 +278,82 @@ public DatasetIterator makeOneShotIterator() {
261278 * @param tf Ops Accessor
262279 * @param tensors A list of {@code Operand<?>} representing components of this dataset (e.g.
263280 * features, labels)
264- * @param outputTypes A list of tensor type classes representing the data type of each component of
265- * this dataset.
281+ * @param outputTypes A list of tensor type classes representing the data type of each component
282+ * of this dataset.
266283 * @return A new `Dataset`
267284 */
268285 public static Dataset fromTensorSlices (
269286 Ops tf , List <Operand <?>> tensors , List <Class <? extends TType >> outputTypes ) {
270287 return new TensorSliceDataset (tf , tensors , outputTypes );
271288 }
272289
290+ /**
291+ * Creates a TFRecordDataset from a file containing TFRecords
292+ *
293+ * @param tf the TensorFlow Ops
294+ * @param filename the file name that holds the TFRecords
295+ * @param compressionType the compresstion type for the file
296+ * @param bufferSize the buffersize for processing the TFRecords file.
297+ * @return a TFRecordDataset
298+ */
273299 public static Dataset tfRecordDataset (
274300 Ops tf , String filename , String compressionType , long bufferSize ) {
275301 return new TFRecordDataset (
276302 tf , tf .constant (filename ), tf .constant (compressionType ), tf .constant (bufferSize ));
277303 }
278304
305+ /**
306+ * Creates a TextLineDataset from a file containing one recored per ling.
307+ *
308+ * @param tf the TensorFlow Ops
309+ * @param filename the file name that holds the data records
310+ * @param compressionType the compresstion type for the file
311+ * @param bufferSize the buffersize for processing the records file.
312+ * @return a TextLineDataset
313+ */
279314 public static Dataset textLineDataset (
280315 Ops tf , String filename , String compressionType , long bufferSize ) {
281316 return new TextLineDataset (
282317 tf , tf .constant (filename ), tf .constant (compressionType ), tf .constant (bufferSize ));
283318 }
284319
285- /** Get the variant tensor representing this dataset. */
320+ /**
321+ * Gets the variant tensor representing this dataset.
322+ *
323+ * @return the variant tensor representing this dataset.
324+ */
286325 public Operand <?> getVariant () {
287326 return variant ;
288327 }
289328
290- /** Get a list of output types for each component of this dataset. */
329+ /**
330+ * Gets a list of output types for each component of this dataset.
331+ *
332+ * @return list of output types for each component of this dataset.
333+ */
291334 public List <Class <? extends TType >> getOutputTypes () {
292335 return this .outputTypes ;
293336 }
294337
295- /** Get a list of shapes for each component of this dataset. */
338+ /**
339+ * Gets a list of shapes for each component of this dataset.
340+ *
341+ * @return a list of shapes for each component of this dataset.
342+ */
296343 public List <Shape > getOutputShapes () {
297344 return this .outputShapes ;
298345 }
299346
347+ /**
348+ * Gets the TensorFlow Ops instance for this dataset
349+ *
350+ * @return the TensorFlow Ops instance for this dataset
351+ */
300352 public Ops getOpsInstance () {
301353 return this .tf ;
302354 }
303355
356+ /** {@inheritDoc} */
304357 @ Override
305358 public String toString () {
306359 return "Dataset{"
0 commit comments