Rate this Page

torch.Tensor.real#

Tensor.real#

Returns a new tensor containing real values of theself tensor for a complex-valued input tensor.The returned tensor andself share the same underlying storage.

Returnsself ifself is a real-valued tensor tensor.

Example:

>>>x=torch.randn(4,dtype=torch.cfloat)>>>xtensor([(0.3100+0.3553j), (-0.5445-0.7896j), (-1.6492-0.0633j), (-0.0638-0.8119j)])>>>x.realtensor([ 0.3100, -0.5445, -1.6492, -0.0638])