shape

open val shape: Shape

shape indicates the number of dimension of a tensor and the length of each dimension. If the shape of the tensor is 3x4x5 then the value of shape is Shape(3,4,5).

Samples

import org.diffkt.FloatScalar
import org.diffkt.reshape
import org.diffkt.tensorOf
fun main() { 
   //sampleStart 
   val tensor = tensorOf(1.0f, 2.0f, 3.0f, 4.0f).reshape(2,2)
val shape = tensor.shape
println("shape = ${shape}")
// output should be
// shape = Shape(2, 2) 
   //sampleEnd
}