Class/Object

org.platanios.tensorflow.api.tensors

Tensor

Related Docs: object Tensor | package tensors

Permalink

class Tensor[+D <: types.DataType] extends TensorLike[D] with utilities.Closeable with Serializable

Tensor (i.e., multi-dimensional array).

Tensors are the main data structure underlying all operations in TensorFlow. They represent multi-dimensional arrays of various data types (e.g., FLOAT32). Operations involving tensors can be of two types:

val a = Tensor(2.0, 4.5, 3.0, -1.2)
val b = Tensor(Tensor(0.2, 0.4), Tensor(-2.3, 5.0))
a.reshape(Shape(2, 2)) + b == Tensor(Tensor(2.2, 4.9), Tensor(0.7, 3.8))
val a = tf.placeholder(FLOAT64, Shape(4))               // Symbolic placeholder for value of a
val b = tf.placeholder(FLOAT64, Shape(2, 2))            // Symbolic placeholder for the value of b
val add = tf.reshape(a, Shape(2, 2)) + b                // Symbolic representation of the computation
val result = Session.run(
  feeds = Map(
    a -> Tensor(2.0, 4.5, 3.0, -1.2),
    b -> Tensor(Tensor(0.2, 0.4), Tensor(-2.3, 5.0))),
  fetches = add)                                        // Performs the actual computation
result == Tensor(Tensor(2.2, 4.9), Tensor(0.7, 3.8))

// TODO: [OPS] Update doc when we enrich op outputs similarly to tensors.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Tensor
  2. Serializable
  3. Closeable
  4. TensorLike
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Tensor(nativeHandleWrapper: NativeHandleWrapper, closeFn: () ⇒ Unit)

    Permalink
    Attributes
    protected

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def apply(firstIndexer: core.Indexer, otherIndexers: core.Indexer*): Tensor[D]

    Permalink
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def close(): Unit

    Permalink

    Closes this Tensor and releases any resources associated with it.

    Closes this Tensor and releases any resources associated with it. Note that an Tensor is not usable after it has been closed.

    Definition Classes
    TensorCloseable
  8. val closeFn: () ⇒ Unit

    Permalink
    Attributes
    protected
    Definition Classes
    TensorCloseable
  9. def copyToDevice(device: String): Tensor[D]

    Permalink

    Returns a copy of this tensor on the provided device.

    Returns a copy of this tensor on the provided device.

    device

    Device name. For example, "CPU:0", or "GPU:2".

  10. def cpu(): Tensor[D]

    Permalink

    Returns a copy of this tensor on the CPU.

  11. val dataType: D

    Permalink

    Data type of this tensor.

    Data type of this tensor.

    Definition Classes
    TensorTensorLike
  12. val device: String

    Permalink

    Device in which the tensor is stored.

    Device in which the tensor is stored.

    Definition Classes
    TensorTensorLike
  13. def entriesIterator: Iterator[D.ScalaType]

    Permalink
  14. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. def equals(that: Any): Boolean

    Permalink
    Definition Classes
    Tensor → AnyRef → Any
  16. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  18. def gpu(gpuIndex: Int = 0): Tensor[D]

    Permalink

    Returns a copy of this tensor on the GPU.

    Returns a copy of this tensor on the GPU.

    gpuIndex

    Index of the GPU to use.

  19. def hashCode(): Int

    Permalink
    Definition Classes
    Tensor → AnyRef → Any
  20. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  21. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  22. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  23. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. def rank: Int

    Permalink

    Rank of this tensor (i.e., number of dimensions).

  25. def scalar: D.ScalaType

    Permalink
    Annotations
    @throws( ... )
  26. val shape: core.Shape

    Permalink

    Shape of this tensor.

    Shape of this tensor.

    Definition Classes
    TensorTensorLike
  27. def size: Long

    Permalink

    Number of elements contained in this tensor.

  28. def slice(firstIndexer: core.Indexer, otherIndexers: core.Indexer*): Tensor[D]

    Permalink
  29. def summarize(maxEntries: Int = 6, flattened: Boolean = false, includeInfo: Boolean = true): String

    Permalink

    Returns a summary of the contents of this tensor.

    Returns a summary of the contents of this tensor.

    maxEntries

    Maximum number of entries to show for each axis/dimension. If the size of an axis exceeds maxEntries, the output of that axis will be shortened to the first and last three elements. Defaults to 6. Values below 6 are ignored.

    flattened

    If true, the summary is flattened to one line. Otherwise, the summary may span multiple lines.

    includeInfo

    If true, the data type and the shape of the tensor are explicitly included in the summary. Otherwise, they are not.

    returns

    Tensor summary.

  30. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  31. def toOutput: ops.Output

    Permalink
  32. def toProto: TensorProto

    Permalink

    Converts this object to its corresponding ProtoBuf object.

    Converts this object to its corresponding ProtoBuf object.

    returns

    ProtoBuf object corresponding to this object.

    Definition Classes
    TensorSerializable
  33. def toString(): String

    Permalink
    Definition Classes
    Tensor → AnyRef → Any
  34. def toTensor: Tensor[D]

    Permalink

    Returns this tensor.

    Returns this tensor.

    Definition Classes
    TensorTensorLike
  35. def toTensorIndexedSlices: TensorIndexedSlices[D]

    Permalink

    Returns an TensorIndexedSlices that has the same value as this TensorLike.

    Returns an TensorIndexedSlices that has the same value as this TensorLike.

    returns

    TensorIndexedSlices that has the same value as this TensorLike.

    Definition Classes
    TensorTensorLike
  36. def toTensorProto: TensorProto

    Permalink

    Constructs and returns a TensorProto object that represents this tensor.

    Constructs and returns a TensorProto object that represents this tensor.

    returns

    Constructed TensorProto.

  37. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. def writeNPY(file: Path, fortranOrder: Boolean = false): Unit

    Permalink

    Writes this tensor to the provided file, using the Numpy (i.e., .npy) file format.

    Writes this tensor to the provided file, using the Numpy (i.e., .npy) file format. Note that this method will replace the file, if it already exists.

Inherited from Serializable

Inherited from utilities.Closeable

Inherited from TensorLike[D]

Inherited from AnyRef

Inherited from Any

Ungrouped