Jovian
⭐️
Sign In
In [1]:
import torch
In [3]:
a = torch.FloatTensor([float('inf')])
In [4]:
a
Out[4]:
tensor([inf])
In [5]:
t1 = torch.tensor(4.)
In [6]:
t1
Out[6]:
tensor(4.)
In [7]:
t0 = torch.tensor(float('inf'))
In [8]:
t0
Out[8]:
tensor(inf)
In [9]:
t2 = torch.tensor([1,2,3,4])
In [10]:
t2
Out[10]:
tensor([1, 2, 3, 4])
In [11]:
t1.shape
Out[11]:
torch.Size([])
In [12]:
t2.shape
Out[12]:
torch.Size([4])
In [13]:
t2.dtype
Out[13]:
torch.int64
In [19]:
x = torch.tensor(3.)
w = torch.tensor(4.,requires_grad=True)
b = torch.tensor(5.,requires_grad=True)
In [21]:
y = w*x+b
y
Out[21]:
tensor(17., grad_fn=<AddBackward0>)
In [22]:
y.backward()
In [23]:
x.grad
In [24]:
w.grad
Out[24]:
tensor(3.)
In [25]:
b.grad
Out[25]:
tensor(1.)
In [26]:
import numpy as np
a = np.ones((2,2))
b = torch.tensor(a)
In [27]:
b[0,1] = 3
In [28]:
b
Out[28]:
tensor([[1., 3.],
        [1., 1.]], dtype=torch.float64)
In [29]:
a
Out[29]:
array([[1., 1.],
       [1., 1.]])
In [30]:
c = torch.from_numpy(a)
In [32]:
c[0,1] = 4
In [33]:
a
Out[33]:
array([[1., 4.],
       [1., 1.]])
In [35]:
pip install jovian --upgrade
Requirement already up-to-date: jovian in c:\users\qwx753507\desktop\mypy\lib\site-packages (0.1.62) Requirement already satisfied, skipping upgrade: requests in c:\users\qwx753507\desktop\mypy\lib\site-packages (from jovian) (2.22.0) Requirement already satisfied, skipping upgrade: uuid in c:\users\qwx753507\desktop\mypy\lib\site-packages (from jovian) (1.30) Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\qwx753507\desktop\mypy\lib\site-packages (from requests->jovian) (1.25.3) Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in c:\users\qwx753507\desktop\mypy\lib\site-packages (from requests->jovian) (2019.6.16) Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in c:\users\qwx753507\desktop\mypy\lib\site-packages (from requests->jovian) (3.0.4) Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in c:\users\qwx753507\desktop\mypy\lib\site-packages (from requests->jovian) (2.8) Note: you may need to restart the kernel to use updated packages.
In [36]:
import jovian
In [ ]:
jovian.commit()
[jovian] Saving notebook..
In [ ]: