Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Introduction to Deep Learning with PyTorch

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

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)
Code bewerken en uitvoeren