形状
code:shape01.py
import numpy as np
import torch as pt
print('# 配列型のshape')
x1 = np.random.random(2, 3) # (2, 3)の乱数配列 print(x1, x1.shape)
y1 = np.random.random(2, 3, 4) # (2, 3, 4)の乱数配列 print(y1, y1.shape)
print('# テンソル型のshape')
x2 = pt.tensor(x1)
y2 = pt.tensor(y1)
print(y2, y2.shape)
print(y2, y2.shape)