Jovian
⭐️
Sign In
In [2]:
import jovian 
import torch
In [3]:
# Vector
t2 = torch.tensor([1.,2,3,4])
print(t2)
tensor([1., 2., 3., 4.])
In [4]:
# Matrix
t3 = torch.tensor([[5.,6],[7,8],[9,10]])
print(t3)
tensor([[ 5., 6.], [ 7., 8.], [ 9., 10.]])
In [5]:
# 3-dimensional array
t4 = torch.tensor([
    [[11,12,13],
    [13,14,15]],
    [[15,16,17],
     [17,18,19.]]])
print(t4)
tensor([[[11., 12., 13.], [13., 14., 15.]], [[15., 16., 17.], [17., 18., 19.]]])
In [6]:
import numpy as np
x = np.array([[1,2],[3,4]])
print(x)
[[1 2] [3 4]]
In [7]:
y = torch.from_numpy(x)
print(y,type(y))
tensor([[1, 2], [3, 4]], dtype=torch.int32) <class 'torch.Tensor'>
In [ ]:
jovian.commit("01-pytorch-basics.ipynb")
[jovian] Saving notebook..
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]: