torch.Tensor.type_as¶ Tensor.type_as(tensor) → Tensor¶ 返回此张量,并将其类型转换为给定张量的类型。 如果张量已经是正确的类型,则此操作无效。这等效于 self.type(tensor.type()) 参数 tensor (Tensor) – 具有所需类型的张量