开始使用免费开始使用

检查与相加张量

在采集温度数据时,您发现读数整体偏低 2 度。请在使用 torch 验证 temperatures 张量的形状和数据类型与 adjustment 张量兼容后,为 temperatures 张量加上 2 度。

已为您加载 torch 库和 temperatures 张量。

本练习是课程的一部分

使用 PyTorch 的深度学习入门

查看课程

交互式实操练习

通过完成这段示例代码来试试这个练习。

adjustment = torch.tensor([[2, 2, 2], [2, 2, 2]])

# Display the shape of the adjustment tensor
print("Adjustment shape:", adjustment.____)

# Display the type of the adjustment tensor
print("Adjustment type:", adjustment.____)

print("Temperatures shape:", temperatures.shape)
print("Temperatures type:", temperatures.dtype)
编辑并运行代码