# ---
# 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
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/msiplab/AtipWork/blob/develop/python/sample01_04.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + id="ASravSQCbwSi"
# 配列の生成
# 
# 画像処理特論
# 
# 村松 正吾 
# 
# 動作確認: Python 3.7, PyTorch 1.8

# + id="oFFz5YQDbwSj"
# Creation of arrays
# 
# Advanced Topics in Image Processing
# 
# Shogo MURAMATSU
# 
# Verified: Python 3.7, PyTorch 1.8
import torch

# + id="jlXxEPUHbwSk"
# (Clear workspace)
#clear


# + id="Jn8ylcEkbwSl"
# (Create array of all zeros)

X = torch.zeros(2,3) # zeros array of size 2x3

# + id="neiZhW5RbwSl"
# (Create array of all ones)

Y = torch.ones(3,4) # ones array of size 3x4

# + id="2ziYUgvwbwSm"
# (Create array of random numbers)

Z = torch.rand(2,3,4) # random array of size 2x3x4

# + id="HFweSzUBbwSn" outputId="1eb9fc94-a6e1-4dba-b54e-6e59d484bbca" colab={"base_uri": "https://localhost:8080/"}
# (Array size)

print('Size of X')
print(X.size())

print('Size of Y')
print(Y.size())

print('Size of Z')
print(Z.size())

# + id="5i1_z0FqbwSn" outputId="619779cc-d36e-4963-bef6-a5f9cd5752c9" colab={"base_uri": "https://localhost:8080/"}
# (Array type)

print('Type of X')
print(X.dtype)

L = torch.zeros(2,3,dtype=torch.bool)
print('Type of L')
print(L.dtype)

U = torch.zeros(2,3,dtype=torch.uint8)
print('Type of U')
print(U.dtype)

I = torch.zeros(2,3,dtype=torch.int16)
print('Type of I')
print(I.dtype)

S = torch.zeros(2,3,dtype=torch.float)
print('Type of S')
print(S.dtype)

# + id="znNrNJ4vbwSo"
# (List variables in workspace)

#whos

# + id="oS1FZP83bwSo"
# © Copyright, <NAME>, All rights reserved.

StarcoderdataJupyterScriptsDedupFiltered