- en: TVTensors id: totrans-0 prefs: - PREF_H1 type: TYPE_NORMAL zh: TVTensors - en: 原文:[https://pytorch.org/vision/stable/tv_tensors.html](https://pytorch.org/vision/stable/tv_tensors.html) id: totrans-1 prefs: - PREF_BQ type: TYPE_NORMAL zh: 原文:[https://pytorch.org/vision/stable/tv_tensors.html](https://pytorch.org/vision/stable/tv_tensors.html) - en: TVTensors are [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.2)") subclasses which the v2 [transforms](transforms.html#transforms) use under the hood to dispatch their inputs to the appropriate lower-level kernels. Most users do not need to manipulate TVTensors directly. id: totrans-2 prefs: [] type: TYPE_NORMAL zh: TVTensors是[`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "(在PyTorch v2.2中)")的子类,v2 [transforms](transforms.html#transforms)在内部使用它们来将输入分派到适当的底层内核。大多数用户不需要直接操作TVTensors。 - en: Refer to [Getting started with transforms v2](auto_examples/transforms/plot_transforms_getting_started.html#sphx-glr-auto-examples-transforms-plot-transforms-getting-started-py) for an introduction to TVTensors, or [TVTensors FAQ](auto_examples/transforms/plot_tv_tensors.html#sphx-glr-auto-examples-transforms-plot-tv-tensors-py) for more advanced info. id: totrans-3 prefs: [] type: TYPE_NORMAL zh: 有关TVTensors的介绍,请参阅[开始使用transforms v2](auto_examples/transforms/plot_transforms_getting_started.html#sphx-glr-auto-examples-transforms-plot-transforms-getting-started-py),或者查看[TVTensors FAQ](auto_examples/transforms/plot_tv_tensors.html#sphx-glr-auto-examples-transforms-plot-tv-tensors-py)以获取更多高级信息。 - en: '| [`Image`](generated/torchvision.tv_tensors.Image.html#torchvision.tv_tensors.Image "torchvision.tv_tensors.Image")(data, *[, dtype, device, requires_grad]) | [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.2)") subclass for images. |' id: totrans-4 prefs: [] type: TYPE_TB zh: '| [`Image`](generated/torchvision.tv_tensors.Image.html#torchvision.tv_tensors.Image "torchvision.tv_tensors.Image")(data, *[, dtype, device, requires_grad]) | 用于图像的[`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "(在PyTorch v2.2中)")子类。 |' - en: '| [`Video`](generated/torchvision.tv_tensors.Video.html#torchvision.tv_tensors.Video "torchvision.tv_tensors.Video")(data, *[, dtype, device, requires_grad]) | [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.2)") subclass for videos. |' id: totrans-5 prefs: [] type: TYPE_TB zh: '| [`Video`](generated/torchvision.tv_tensors.Video.html#torchvision.tv_tensors.Video "torchvision.tv_tensors.Video")(data, *[, dtype, device, requires_grad]) | 用于视频的[`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "(在PyTorch v2.2中)")子类。 |' - en: '| [`BoundingBoxFormat`](generated/torchvision.tv_tensors.BoundingBoxFormat.html#torchvision.tv_tensors.BoundingBoxFormat "torchvision.tv_tensors.BoundingBoxFormat")(value) | Coordinate format of a bounding box. |' id: totrans-6 prefs: [] type: TYPE_TB zh: '| [`BoundingBoxFormat`](generated/torchvision.tv_tensors.BoundingBoxFormat.html#torchvision.tv_tensors.BoundingBoxFormat "torchvision.tv_tensors.BoundingBoxFormat")(value) | 边界框的坐标格式。 |' - en: '| [`BoundingBoxes`](generated/torchvision.tv_tensors.BoundingBoxes.html#torchvision.tv_tensors.BoundingBoxes "torchvision.tv_tensors.BoundingBoxes")(data, *, format, canvas_size) | [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.2)") subclass for bounding boxes. |' id: totrans-7 prefs: [] type: TYPE_TB zh: '| [`BoundingBoxes`](generated/torchvision.tv_tensors.BoundingBoxes.html#torchvision.tv_tensors.BoundingBoxes "torchvision.tv_tensors.BoundingBoxes")(data, *, format, canvas_size) | 用于边界框的[`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "(在PyTorch v2.2中)")子类。 |' - en: '| [`Mask`](generated/torchvision.tv_tensors.Mask.html#torchvision.tv_tensors.Mask "torchvision.tv_tensors.Mask")(data, *[, dtype, device, requires_grad]) | [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.2)") subclass for segmentation and detection masks. |' id: totrans-8 prefs: [] type: TYPE_TB zh: '| [`Mask`](generated/torchvision.tv_tensors.Mask.html#torchvision.tv_tensors.Mask "torchvision.tv_tensors.Mask")(data, *[, dtype, device, requires_grad]) | 用于分割和检测掩码的[`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "(在PyTorch v2.2中)")子类。 |' - en: '| [`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor "torchvision.tv_tensors.TVTensor") | Base class for all TVTensors. |' id: totrans-9 prefs: [] type: TYPE_TB zh: '| [`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor "torchvision.tv_tensors.TVTensor") | 所有TVTensors的基类。 |' - en: '| [`set_return_type`](generated/torchvision.tv_tensors.set_return_type.html#torchvision.tv_tensors.set_return_type "torchvision.tv_tensors.set_return_type")(return_type) | Set the return type of torch operations on [`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor "torchvision.tv_tensors.TVTensor"). |' id: totrans-10 prefs: [] type: TYPE_TB zh: '| [`set_return_type`](generated/torchvision.tv_tensors.set_return_type.html#torchvision.tv_tensors.set_return_type "torchvision.tv_tensors.set_return_type")(return_type) | 设置[`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor "torchvision.tv_tensors.TVTensor")上torch操作的返回类型。 |' - en: '| [`wrap`](generated/torchvision.tv_tensors.wrap.html#torchvision.tv_tensors.wrap "torchvision.tv_tensors.wrap")(wrappee, *, like, **kwargs) | Convert a [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.2)") (`wrappee`) into the same [`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor "torchvision.tv_tensors.TVTensor") subclass as `like`. |' id: totrans-11 prefs: [] type: TYPE_TB zh: '| [`wrap`](generated/torchvision.tv_tensors.wrap.html#torchvision.tv_tensors.wrap "torchvision.tv_tensors.wrap")(wrappee, *, like, **kwargs) | 将[`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch.Tensor "(在PyTorch v2.2中)") (`wrappee`)转换为与`like`相同的[`TVTensor`](generated/torchvision.tv_tensors.TVTensor.html#torchvision.tv_tensors.TVTensor "torchvision.tv_tensors.TVTensor")子类。 |'