MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / create

Method create

tensorflow/java/src/main/java/org/tensorflow/Tensor.java:104–116  ·  view source on GitHub ↗

Creates a Tensor from a Java object. A Tensor is a multi-dimensional array of elements of a limited set of types. Not all Java objects can be converted to a Tensor. In particular, the argument obj must be either a primitive (float, double, int, long, boolean, byte) or a m

(Object obj, Class<T> type)

Source from the content-addressed store, hash-verified

102 * system.
103 */
104 @SuppressWarnings("unchecked")
105 public static <T> Tensor<T> create(Object obj, Class<T> type) {
106 DataType dtype = DataType.fromClass(type);
107 if (!objectCompatWithType(obj, dtype)) {
108 throw new IllegalArgumentException(
109 "DataType of object does not match T (expected "
110 + dtype
111 + ", got "
112 + dataTypeOf(obj)
113 + ")");
114 }
115 return (Tensor<T>) create(obj, dtype);
116 }
117
118 /**
119 * Creates a tensor from an object whose class is inspected to figure out what the underlying data

Callers 15

feedMethod · 0.95
createWithByteBufferMethod · 0.95
createWithTypedBufferMethod · 0.95
testUInt8TensorMethod · 0.95
failOnArbitraryObjectMethod · 0.95
useAfterCloseMethod · 0.95
constantOpMethod · 0.95
constantMethod · 0.95
createMethod · 0.95

Calls 15

fromClassMethod · 0.95
objectCompatWithTypeMethod · 0.95
dataTypeOfMethod · 0.95
numDimensionsMethod · 0.95
fillShapeMethod · 0.95
elemByteSizeMethod · 0.95
numElementsMethod · 0.95
allocateMethod · 0.95
setValueMethod · 0.95
allocateScalarBytesMethod · 0.95
allocateForBufferMethod · 0.95

Tested by 11

createWithByteBufferMethod · 0.76
createWithTypedBufferMethod · 0.76
testUInt8TensorMethod · 0.76
failOnArbitraryObjectMethod · 0.76
useAfterCloseMethod · 0.76
constantOpMethod · 0.76
constantMethod · 0.76
createMethod · 0.76