aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/java
diff options
context:
space:
mode:
authorGravatar karl@kubx.ca <karl@kubx.ca>2018-08-02 21:25:03 -0400
committerGravatar karl@kubx.ca <karl@kubx.ca>2018-08-02 21:25:03 -0400
commit9aaa9b16bae613c52f576bda8c1bf75915a9090f (patch)
tree0249e10896f9c0a06ff85f136f990ab4ed7df4db /tensorflow/java
parentdde0bf5051591b013b9eee131cd18af9a5c50ebf (diff)
2nd code review: Documentation fixes
Diffstat (limited to 'tensorflow/java')
-rw-r--r--tensorflow/java/src/main/java/org/tensorflow/DataType.java2
-rw-r--r--tensorflow/java/src/main/java/org/tensorflow/op/core/Constant.java124
2 files changed, 63 insertions, 63 deletions
diff --git a/tensorflow/java/src/main/java/org/tensorflow/DataType.java b/tensorflow/java/src/main/java/org/tensorflow/DataType.java
index 9dfa9cc68c..516655040b 100644
--- a/tensorflow/java/src/main/java/org/tensorflow/DataType.java
+++ b/tensorflow/java/src/main/java/org/tensorflow/DataType.java
@@ -61,7 +61,7 @@ public enum DataType {
}
/**
- * @return size of an element of this type, in bytes, or -1 if element size is variable
+ * Returns the size of an element of this type, in bytes, or -1 if element size is variable.
*/
public int byteSize() {
return byteSize;
diff --git a/tensorflow/java/src/main/java/org/tensorflow/op/core/Constant.java b/tensorflow/java/src/main/java/org/tensorflow/op/core/Constant.java
index d7a06380c7..00b6726be3 100644
--- a/tensorflow/java/src/main/java/org/tensorflow/op/core/Constant.java
+++ b/tensorflow/java/src/main/java/org/tensorflow/op/core/Constant.java
@@ -38,26 +38,6 @@ import org.tensorflow.op.annotation.Operator;
public final class Constant<T> extends PrimitiveOp implements Operand<T> {
/**
- * Create a {@link DataType#INT32} constant with data from the given buffer.
- *
- * <p>Creates a constant with the given shape by copying elements from the buffer (starting from
- * its current position) into the tensor. For example, if {@code shape = {2,3} } (which represents
- * a 2x3 matrix) then the buffer must have 6 elements remaining, which will be consumed by this
- * method.
- *
- * @param scope is a scope used to add the underlying operation.
- * @param shape the tensor shape.
- * @param data a buffer containing the tensor data.
- * @return an integer constant
- * @throws IllegalArgumentException If the tensor shape is not compatible with the buffer
- */
- public static Constant<Integer> create(Scope scope, long[] shape, IntBuffer data) {
- try (Tensor<Integer> value = Tensor.create(shape, data)) {
- return createWithTensor(scope, value);
- }
- }
-
- /**
* Creates a constant containing a single {@code int} element.
*
* @param scope is a scope used to add the underlying operation.
@@ -135,7 +115,7 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
}
/**
- * Create a {@link DataType#FLOAT} constant with data from the given buffer.
+ * Create a {@link DataType#INT32} constant with data from the given buffer.
*
* <p>Creates a constant with the given shape by copying elements from the buffer (starting from
* its current position) into the tensor. For example, if {@code shape = {2,3} } (which represents
@@ -145,11 +125,11 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
* @param scope is a scope used to add the underlying operation.
* @param shape the tensor shape.
* @param data a buffer containing the tensor data.
- * @return a float constant
+ * @return an integer constant
* @throws IllegalArgumentException If the tensor shape is not compatible with the buffer
*/
- public static Constant<Float> create(Scope scope, long[] shape, FloatBuffer data) {
- try (Tensor<Float> value = Tensor.create(shape, data)) {
+ public static Constant<Integer> create(Scope scope, long[] shape, IntBuffer data) {
+ try (Tensor<Integer> value = Tensor.create(shape, data)) {
return createWithTensor(scope, value);
}
}
@@ -232,7 +212,7 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
}
/**
- * Create a {@link DataType#DOUBLE} constant with data from the given buffer.
+ * Create a {@link DataType#FLOAT} constant with data from the given buffer.
*
* <p>Creates a constant with the given shape by copying elements from the buffer (starting from
* its current position) into the tensor. For example, if {@code shape = {2,3} } (which represents
@@ -242,11 +222,11 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
* @param scope is a scope used to add the underlying operation.
* @param shape the tensor shape.
* @param data a buffer containing the tensor data.
- * @return a double constant
+ * @return a float constant
* @throws IllegalArgumentException If the tensor shape is not compatible with the buffer
*/
- public static Constant<Double> create(Scope scope, long[] shape, DoubleBuffer data) {
- try (Tensor<Double> value = Tensor.create(shape, data)) {
+ public static Constant<Float> create(Scope scope, long[] shape, FloatBuffer data) {
+ try (Tensor<Float> value = Tensor.create(shape, data)) {
return createWithTensor(scope, value);
}
}
@@ -329,7 +309,7 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
}
/**
- * Create a {@link DataType#INT64} constant with data from the given buffer.
+ * Create a {@link DataType#DOUBLE} constant with data from the given buffer.
*
* <p>Creates a constant with the given shape by copying elements from the buffer (starting from
* its current position) into the tensor. For example, if {@code shape = {2,3} } (which represents
@@ -339,11 +319,11 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
* @param scope is a scope used to add the underlying operation.
* @param shape the tensor shape.
* @param data a buffer containing the tensor data.
- * @return a long constant
+ * @return a double constant
* @throws IllegalArgumentException If the tensor shape is not compatible with the buffer
*/
- public static Constant<Long> create(Scope scope, long[] shape, LongBuffer data) {
- try (Tensor<Long> value = Tensor.create(shape, data)) {
+ public static Constant<Double> create(Scope scope, long[] shape, DoubleBuffer data) {
+ try (Tensor<Double> value = Tensor.create(shape, data)) {
return createWithTensor(scope, value);
}
}
@@ -426,6 +406,26 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
}
/**
+ * Create a {@link DataType#INT64} constant with data from the given buffer.
+ *
+ * <p>Creates a constant with the given shape by copying elements from the buffer (starting from
+ * its current position) into the tensor. For example, if {@code shape = {2,3} } (which represents
+ * a 2x3 matrix) then the buffer must have 6 elements remaining, which will be consumed by this
+ * method.
+ *
+ * @param scope is a scope used to add the underlying operation.
+ * @param shape the tensor shape.
+ * @param data a buffer containing the tensor data.
+ * @return a long constant
+ * @throws IllegalArgumentException If the tensor shape is not compatible with the buffer
+ */
+ public static Constant<Long> create(Scope scope, long[] shape, LongBuffer data) {
+ try (Tensor<Long> value = Tensor.create(shape, data)) {
+ return createWithTensor(scope, value);
+ }
+ }
+
+ /**
* Creates a constant containing a single {@code boolean} element.
*
* @param scope is a scope used to add the underlying operation.
@@ -503,7 +503,7 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
}
/**
- * Creates a String constant using the default, UTF-8 encoding.
+ * Creates a {@code String} constant using the default, UTF-8 encoding.
*
* @param scope is a scope used to add the underlying operation.
* @param data The string to put into the new constant.
@@ -514,7 +514,7 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
}
/**
- * Creates a String constant using a specified encoding.
+ * Creates a {@code String} constant using a specified encoding.
*
* @param scope is a scope used to add the underlying operation.
* @param charset The encoding from String to bytes.
@@ -528,29 +528,7 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
}
/**
- * Create a constant with data from the given buffer.
- *
- * <p>Creates a Constant with the provided shape of any type where the constant data has been
- * encoded into {@code data} as per the specification of the TensorFlow <a
- * href="https://www.tensorflow.org/code/tensorflow/c/c_api.h">C
- * API</a>.
- *
- * @param scope is a scope used to add the underlying operation.
- * @param type the tensor datatype.
- * @param shape the tensor shape.
- * @param data a buffer containing the tensor data.
- * @return a constant of type `type`
- * @throws IllegalArgumentException If the tensor datatype or shape is not compatible with the
- * buffer
- */
- public static <T> Constant<T> create(Scope scope, Class<T> type, long[] shape, ByteBuffer data) {
- try (Tensor<T> value = Tensor.create(type, shape, data)) {
- return createWithTensor(scope, value);
- }
- }
-
- /**
- * Creates a rank-1 constant of {@code byte} elements.
+ * Creates a constant containing a single {@code String} element, represented as an array of {@code byte}s.
*
* @param scope is a scope used to add the underlying operation.
* @param data An array containing the values to put into the new constant. String elements are
@@ -561,7 +539,7 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
}
/**
- * Creates a rank-2 constant of {@code byte} elements.
+ * Creates a rank-1 constant of {@code String} elements, each represented as an array of {@code byte}s.
*
* @param scope is a scope used to add the underlying operation.
* @param data An array containing the values to put into the new constant. String elements are
@@ -572,7 +550,7 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
}
/**
- * Creates a rank-3 constant of {@code byte} elements.
+ * Creates a rank-2 constant of {@code String} elements, each represented as an array of {@code byte}s.
*
* @param scope is a scope used to add the underlying operation.
* @param data An array containing the values to put into the new constant. String elements are
@@ -583,7 +561,7 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
}
/**
- * Creates a rank-4 constant of {@code byte} elements.
+ * Creates a rank-3 constant of {@code String} elements, each represented as an array of {@code byte}s.
*
* @param scope is a scope used to add the underlying operation.
* @param data An array containing the values to put into the new constant. String elements are
@@ -594,7 +572,7 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
}
/**
- * Creates a rank-5 constant of {@code byte} elements.
+ * Creates a rank-4 constant of {@code String} elements, each represented as an array of {@code byte}s.
*
* @param scope is a scope used to add the underlying operation.
* @param data An array containing the values to put into the new constant. String elements are
@@ -605,7 +583,7 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
}
/**
- * Creates a rank-6 constant of {@code byte} elements.
+ * Creates a rank-5 constant of {@code String} elements, each represented as an array of {@code byte}s.
*
* @param scope is a scope used to add the underlying operation.
* @param data An array containing the values to put into the new constant. String elements are
@@ -616,6 +594,28 @@ public final class Constant<T> extends PrimitiveOp implements Operand<T> {
}
/**
+ * Create a constant with data from the given buffer.
+ *
+ * <p>Creates a Constant with the provided shape of any type where the constant data has been
+ * encoded into {@code data} as per the specification of the TensorFlow <a
+ * href="https://www.tensorflow.org/code/tensorflow/c/c_api.h">C
+ * API</a>.
+ *
+ * @param scope is a scope used to add the underlying operation.
+ * @param type the tensor datatype.
+ * @param shape the tensor shape.
+ * @param data a buffer containing the tensor data.
+ * @return a constant of type `type`
+ * @throws IllegalArgumentException If the tensor datatype or shape is not compatible with the
+ * buffer
+ */
+ public static <T> Constant<T> create(Scope scope, Class<T> type, long[] shape, ByteBuffer data) {
+ try (Tensor<T> value = Tensor.create(type, shape, data)) {
+ return createWithTensor(scope, value);
+ }
+ }
+
+ /**
* Create a constant from a Java object.
*
* <p>The argument {@code object} is first converted into a Tensor using {@link