# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + colab={"base_uri": "https://localhost:8080/"} id="eT7G5JxJX6F8" outputId="c2863682-9061-4d73-dc87-c958364e78ef"
import torch
a=torch.tensor([[1,2,3],[5,6,7]]) # creates the 2d tensor
print(a)
print(type(a))
print(a.ndim)

# + colab={"base_uri": "https://localhost:8080/"} id="EcbhYpEtZMq0" outputId="d6b5023b-0b78-4ecd-8f70-3835ce7db0a4"
# creating the 3d tensor
d=torch.tensor([[[3,5],
                 [0,2],
                 [1,9]]])
print(d)
print(d.ndim)

# + colab={"base_uri": "https://localhost:8080/"} id="okPbtWqyYDMY" outputId="ecfd1698-0a29-4a0e-c05c-254c96c85fff"
b=torch.arange(start=0,step=3,end=100) # arange the number from 0 to 100 with step size 3
print(b)
print(type(b))

# + colab={"base_uri": "https://localhost:8080/"} id="c7Z26rgmYZAI" outputId="80520eed-1d88-4236-e8d9-28fafe8cda7a"
b=torch.zeros(3,3) # creates the tensor of size 3X3
print(b)

# + colab={"base_uri": "https://localhost:8080/"} id="266-rrq9Yf7S" outputId="b882a61b-7f9b-41c7-e8f5-4165682443aa"
c=torch.zeros_like(b) # creates the same tensor of given size b
print(c)

# + colab={"base_uri": "https://localhost:8080/"} id="4g9SFMKpYn3b" outputId="b47dbe17-169e-4807-a64b-c9316aa57a7d"
# accessing the values using slicing 
d

# + colab={"base_uri": "https://localhost:8080/"} id="N60i8ucvZgEA" outputId="96472402-3cf3-4ce7-8dd6-d0661513c510"
d[0,1]

# + colab={"base_uri": "https://localhost:8080/"} id="R8ORhL7_Zi65" outputId="73756836-e61c-416e-dc47-ad033f2db991"
d[:,:1]

# + colab={"base_uri": "https://localhost:8080/"} id="IyAzM2UbZ3Z3" outputId="90c0b7af-f339-4905-e181-aecbbde79f4e"
a

# + colab={"base_uri": "https://localhost:8080/"} id="-Qrx234waW95" outputId="1e8c8fd0-0b6e-4971-bf6e-7ab17768ce33"
a[:,:2]

# + colab={"base_uri": "https://localhost:8080/"} id="IjI8NQxsac-H" outputId="63888ab7-97d8-44ce-ec12-a7f62ae7adb0"
a[1,0]

# + id="jNZyWxOqamMH"


StarcoderdataJupyterScriptsDedupFiltered