Get startedGet started for free

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.

This exercise is part of the course

Introduction to Deep Learning with PyTorch

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

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 and Run Code