Torch::Tensor
Inherits Reference < Object
Constructors
load(filename : String) : self
SourceCreates a tensor from a contiguous slice of numbers, inferring the kind from the element type.
of(values : Array(T), shape) : self forall T
Sourceof(values : Array(T) | Slice(T)) : self forall T
Sourcezeros(shape, kind : Kind = Kind::Float32) : self
Zero-filled tensor of the given kind and shape.
Instance methods
[](index : Int) : Tensor
Sourcec_tensor
Sourcecontiguous?
Sourcecopy_from(other : Tensor) : self
Sourcecopy_to(buf : Slice(T)) : Nil forall T
Copies the tensor data into out; the buffer must be at least size
elements long and match the tensor's element size. Non-CPU tensors are
moved to CPU first.
data_ptr
Sourcedefined?
Sourcedevice
Sourcedim
Sourcefinalize
Sourceinspect(io : IO) : Nil
Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>
kind
Sourceowned?
Sourceprint
Sourcerequires_grad?
Sourcesave(filename : String) : Nil
Sourceshallow_clone
Sourceshape
Sourcesize
Sourcesparse?
Sourcestrides
Sourceto(kind : Kind) : Tensor
Sourceto_f32
Sourceto_f64
Sourceto_i64
Sourceto_s(io : IO) : Nil
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>