Skip to content

Commit fe7e8e3

Browse files
committed
JavaDoc fixes including Dataset
1 parent 8d45739 commit fe7e8e3

4 files changed

Lines changed: 107 additions & 25 deletions

File tree

‎tensorflow-framework/src/main/java/org/tensorflow/framework/data/Dataset.java‎

Lines changed: 69 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323
import org.tensorflow.framework.data.impl.TakeDataset;
2424
import org.tensorflow.framework.data.impl.TensorSliceDataset;
2525
import org.tensorflow.framework.data.impl.TextLineDataset;
26+
import org.tensorflow.ndarray.Shape;
2627
import org.tensorflow.op.Op;
2728
import org.tensorflow.op.Ops;
28-
import org.tensorflow.ndarray.Shape;
29+
import org.tensorflow.types.family.TType;
2930

3031
import java.util.ArrayList;
3132
import java.util.Arrays;
3233
import java.util.Iterator;
3334
import java.util.List;
3435
import 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{"

‎tensorflow-framework/src/main/java/org/tensorflow/framework/data/DatasetOptional.java‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
public class DatasetOptional {
3232
protected Ops tf;
3333

34+
/**
35+
* Gets the optional variant for this Dataset
36+
* @return the optional variant for this Dataset
37+
*/
3438
public Operand<?> getOptionalVariant() {
3539
return optionalVariant;
3640
}
@@ -39,6 +43,13 @@ public Operand<?> getOptionalVariant() {
3943
private List<Class<? extends TType>> outputTypes;
4044
private List<Shape> outputShapes;
4145

46+
/**
47+
* Creates a DatasetOptional dataset
48+
* @param tf the TensorFlow Ops
49+
* @param optionalVariant the tensor that represents the dataset.
50+
* @param outputTypes a list of output types produced by this data set.
51+
* @param outputShapes a list of output shapes produced by this data set.
52+
*/
4253
public DatasetOptional(
4354
Ops tf, Operand<?> optionalVariant, List<Class<? extends TType>> outputTypes, List<Shape> outputShapes) {
4455
this.tf = tf;
@@ -47,6 +58,11 @@ public DatasetOptional(
4758
this.outputShapes = outputShapes;
4859
}
4960

61+
/**
62+
* Creates a Dataset that is a copy of another Dataset
63+
*
64+
* @param other the other Dataset
65+
*/
5066
protected DatasetOptional(DatasetOptional other) {
5167
this.tf = other.tf;
5268
this.optionalVariant = other.optionalVariant;
@@ -56,12 +72,16 @@ protected DatasetOptional(DatasetOptional other) {
5672

5773

5874

59-
/** Whether this optional has a value. */
75+
/** Gets the indicator of whether this optional has a value.
76+
* @return the indicator of whether this optional has a value.
77+
*/
6078
public Operand<TBool> hasValue() {
6179
return tf.data.optionalHasValue(optionalVariant).hasValue();
6280
}
6381

64-
/** Returns the value of the dataset element represented by this optional, if it exists. */
82+
/** Returns the value of the dataset element represented by this optional, if it exists.
83+
* @return the value of the dataset element represented by this optional, if it exists.
84+
*/
6585
public List<Operand<?>> getValue() {
6686
List<Operand<?>> components = new ArrayList<>();
6787
tf.data
@@ -72,6 +92,14 @@ public List<Operand<?>> getValue() {
7292
return components;
7393
}
7494

95+
/**
96+
* Creates a DatasetOptional from components.
97+
* @param tf the TensorFlow Ops
98+
* @param components the components that constitute the DatasetOptional
99+
* @param outputTypes a list of output types produced by this data set.
100+
* @param outputShapes a list of output shapes produced by this data set.
101+
* @return a a DatasetOptional
102+
*/
75103
public static DatasetOptional fromComponents(
76104
Ops tf,
77105
List<Operand<?>> components,
@@ -81,6 +109,11 @@ public static DatasetOptional fromComponents(
81109
return new DatasetOptional(tf, optionalVariant, outputTypes, outputShapes);
82110
}
83111

112+
/**
113+
* Gets the TensorFlow Ops instance for this dataset
114+
*
115+
* @return the TensorFlow Ops instance for this dataset
116+
*/
84117
public Ops getOpsInstance() {
85118
return tf;
86119
}

‎tensorflow-framework/src/main/java/org/tensorflow/framework/losses/SparseCategoricalCrossentropy.java‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public class SparseCategoricalCrossentropy extends AbstractLoss {
8484
* name, a AbstractLoss Reduction of {@link AbstractLoss#REDUCTION_DEFAULT}, and fromLogits={@link
8585
* #FROM_LOGITS_DEFAULT}.
8686
*
87-
* @param tf the TensorFlow Ops
87+
8888
*/
8989
public SparseCategoricalCrossentropy() {
9090
this(null, FROM_LOGITS_DEFAULT, REDUCTION_DEFAULT, AXIS_DEFAULT);
@@ -104,7 +104,6 @@ public SparseCategoricalCrossentropy(String name) {
104104
* Creates a SparseCategoricalCrossentropy loss using {@link Class#getSimpleName()} as the loss
105105
* name, with Reduction.AUTO and fromLogits={@link #FROM_LOGITS_DEFAULT}.
106106
*
107-
* @param tf the TensorFlow Ops
108107
* @param reduction Type of Reduction to apply to loss.
109108
*/
110109
public SparseCategoricalCrossentropy(Reduction reduction) {
@@ -115,7 +114,6 @@ public SparseCategoricalCrossentropy(Reduction reduction) {
115114
* Creates a SparseCategoricalCrossentropy loss with Reduction.AUTO and fromLogits={@link
116115
* #FROM_LOGITS_DEFAULT}.
117116
*
118-
* @param tf the TensorFlow Ops
119117
* @param name the name of this loss function
120118
* @param reduction Type of Reduction to apply to loss.
121119
*/
@@ -127,7 +125,6 @@ public SparseCategoricalCrossentropy(String name, Reduction reduction) {
127125
* Creates a SparseCategoricalCrossentropy using a AbstractLoss Reduction of {@link
128126
* AbstractLoss#REDUCTION_DEFAULT}, and fromLogits={@link #FROM_LOGITS_DEFAULT}.
129127
*
130-
* @param tf the TensorFlow Ops
131128
* @param name the name of this loss function
132129
* @param fromLogits Whether to interpret predictions as a tensor of logit values
133130
*/
@@ -140,7 +137,6 @@ public SparseCategoricalCrossentropy(String name, boolean fromLogits) {
140137
* name, a AbstractLoss Reduction of {@link AbstractLoss#REDUCTION_DEFAULT} and fromLogits={@link
141138
* #FROM_LOGITS_DEFAULT}.
142139
*
143-
* @param tf the TensorFlow Ops
144140
* @param fromLogits Whether to interpret predictions as a tensor of logit values
145141
*/
146142
public SparseCategoricalCrossentropy(boolean fromLogits) {
@@ -151,7 +147,6 @@ public SparseCategoricalCrossentropy(boolean fromLogits) {
151147
* Creates a SparseCategoricalCrossentropy loss using {@link Class#getSimpleName()} as the loss
152148
* name,
153149
*
154-
* @param tf the TensorFlow Ops
155150
* @param fromLogits Whether to interpret predictions as a tensor of logit values
156151
* @param reduction Type of Reduction to apply to loss.
157152
*/
@@ -162,7 +157,6 @@ public SparseCategoricalCrossentropy(boolean fromLogits, Reduction reduction) {
162157
/**
163158
* Creates a SparseCategoricalCrossentropy
164159
*
165-
* @param tf the TensorFlow Ops
166160
* @param name the name of this loss function
167161
* @param fromLogits Whether to interpret predictions as a tensor of logit values
168162
* @param reduction Type of Reduction to apply to loss.
@@ -184,6 +178,7 @@ public SparseCategoricalCrossentropy(
184178
* range o [0. to 1.]. In Eager Mode, this call will throw {@link IllegalArgumentException}, if
185179
* the predictions values are outside the range o [0. to 1.]
186180
*
181+
* @param tf the TensorFlow Ops
187182
* @param labels the truth values or labels
188183
* @param predictions the predictions, values must be in the range [0. to 1.] inclusive.
189184
* @param sampleWeights Optional SampleWeights acts as a coefficient for the loss. If a scalar is

‎tensorflow-framework/src/main/java/org/tensorflow/framework/regularizers/L1L2.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public L1L2(float l1, float l2) {
5757
/**
5858
* Creates an L1L2 regularizer
5959
*
60+
* @param name the name for this regularizer, if null the class name will be used.
6061
* @param l1 L1 regularization factor, if null it is set to 0.
6162
* @param l2 L2 regularization factor, if null it is set to 0.
6263
* @throws IllegalArgumentException if the l1 or l2 regularization factor is {@link Float#isNaN}

0 commit comments

Comments
 (0)