MulaiMulai sekarang secara gratis

Checking and adding tensors

While collecting temperature data, you notice the readings are off by two degrees. Add two degrees to the temperatures tensor after verifying its shape and data type with torch to ensure compatibility with the adjustment tensor.

The torch library and the temperatures tensor are loaded for you.

Latihan ini adalah bagian dari kursus

Introduction to Deep Learning with PyTorch

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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)
Edit dan Jalankan Kode