Learn practical skills, build real-world projects, and advance your career
# Jovian Commit Essentials
# Please retain and execute this cell without modifying the contents for `jovian.commit` to work
!pip install jovian --upgrade -q
import jovian
jovian.utils.colab.set_colab_file_id('1C3gF-4vIiv_zuTCcwiaAqb2z6BsAts33')
import torch

t1 = torch.tensor(4.)
t1
tensor(4.)
#is a shorthand for 4.0. It is used to indicate to Python (and PyTorch) that you want to create a floating-point number. We can verify this by checking the dtype attribute of our tensor.
t1.dtype
torch.float32
# Vector
t2 = torch.tensor([1., 2, 3, 4])
t2
tensor([1., 2., 3., 4.])
# Matrix
t3 = torch.tensor([[5., 6], 
                   [7, 8], 
                   [9, 10]])
t3
tensor([[ 5.,  6.],
        [ 7.,  8.],
        [ 9., 10.]])