shapeの使い方 (numpy)



Python
Pythonとは
基本的な使い方
・IDLE

・Jupyter Notebook

・Markdown

・コマンドプロンプトで実行

・仮想環境の構築

・仮想環境でIDLEを実行

ライブラリのインストール
・pipの使い方

・numpy , matplotlib等

・graphviz

・pytorch

・Mecab

Pythonの関数:一覧
共通関数
・append , extend

・class

・copy

・csv.reader

・csv.writer

・def , return

・dict , defaultdict

・enumerate

・exit

・for

・if

・import

・in

・input

・lambda

・len

・list

・min/max

・OrderedDict

・open/close

・os

・pickle

・print

・range

・re.split

・read/readline

・round/floor/ceil

・split

・sys.argv

・time

・while

・write

・zip

・特殊メソッド
 ・__name__

 ・__iter__ , __next__

・正規表現、メタ文字

・データの型の種類

・四則演算 (+ , - , * , /)

・コメントアウト (# , ''')

numpy
・append

・arange

・argmax/argmin

・array

・asfarray

・astype , dtype

・digitize

・dot

・hstack/vstack

・linalg.solve

・linspace

・max,min

・mean

・meshgrid

・mgrid

・ndim

・ndmin

・pad

・poly1d

・polyfit

・prod

・random

・reshape

・savetxt/loadtxt

・shape

・std

・transpose

・where

・zeros/zeros_like

scipy
・expit

・imread

・interpolate

・signal.square, sawtooth

matplotlib
・contour

・imshow

・figure

・pcolormesh

・plot

・quiver

・scatter

scikit-learn
・GaussianNB

・KMeans

・KNeighborsClassifier

・SVC

・tree

chaospy

keras

chainer

chainerrl

pandas
・データ抽出

・concat

・DataFrame

・read_excel

pytorch
・BCELoss , MSELoss

・Embedding

・device

・Sequential

・Dataset, Dataloader

・RNN, LSTM

OpenAI gym
・Blackjack-v0

・CartPole-v0

seaborn
・pairplot

tkinter
・frame, grid

・画像表示

・画像を切り取り表示

・画像を保存

目的別
・ステップ関数

・矩形波, 三角波

・1 of K 符号化法

・線形補間

・配列に番号をつける

・ベクトル場を描く

・線形回帰, 多項式回帰

・Bluetooth接続


公開日:2019/1/10         

・In English


■shape関数の説明

配列の形状を返します。類似の関数にreshapeというのがありますが、これは配列の形状を変える関数になります。

■shape関数を使った具体例

以下はnumpyを使用する際に必須の記載です。

import numpy as np


例①

a=np.array([1,2,3,4,5,6,7,8,9,10,11,12])
a.shape

⇒ (12,)


例②

a=np.array([[1,2,3],[4,5,6]])
a.shape

⇒ (2, 3)


なお以下の様にすれば、それぞれの数値を分けて取り出すことが出来ます。

b=a.shape[0]
b

⇒ 2

b , c =a.shape
b

⇒ 2

c

⇒ 3










サブチャンネルあります。⇒ 何かのお役に立てればと

関連記事一覧



Python
Pythonとは
基本的な使い方
・IDLE

・Jupyter Notebook

・Markdown

・コマンドプロンプトで実行

・仮想環境の構築

・仮想環境でIDLEを実行

ライブラリのインストール
・pipの使い方

・numpy , matplotlib等

・graphviz

・pytorch

・Mecab

Pythonの関数:一覧
共通関数
・append , extend

・class

・copy

・csv.reader

・csv.writer

・def , return

・dict , defaultdict

・enumerate

・exit

・for

・if

・import

・in

・input

・lambda

・len

・list

・min/max

・OrderedDict

・open/close

・os

・pickle

・print

・range

・re.split

・read/readline

・round/floor/ceil

・split

・sys.argv

・time

・while

・write

・zip

・特殊メソッド
 ・__name__

 ・__iter__ , __next__

・正規表現、メタ文字

・データの型の種類

・四則演算 (+ , - , * , /)

・コメントアウト (# , ''')

numpy
・append

・arange

・argmax/argmin

・array

・asfarray

・astype , dtype

・digitize

・dot

・hstack/vstack

・linalg.solve

・linspace

・max,min

・mean

・meshgrid

・mgrid

・ndim

・ndmin

・pad

・poly1d

・polyfit

・prod

・random

・reshape

・savetxt/loadtxt

・shape

・std

・transpose

・where

・zeros/zeros_like

scipy
・expit

・imread

・interpolate

・signal.square, sawtooth

matplotlib
・contour

・imshow

・figure

・pcolormesh

・plot

・quiver

・scatter

scikit-learn
・GaussianNB

・KMeans

・KNeighborsClassifier

・SVC

・tree

chaospy

keras

chainer

chainerrl

pandas
・データ抽出

・concat

・DataFrame

・read_excel

pytorch
・BCELoss , MSELoss

・Embedding

・device

・Sequential

・Dataset, Dataloader

・RNN, LSTM

OpenAI gym
・Blackjack-v0

・CartPole-v0

seaborn
・pairplot

tkinter
・frame, grid

・画像表示

・画像を切り取り表示

・画像を保存

目的別
・ステップ関数

・矩形波, 三角波

・1 of K 符号化法

・線形補間

・配列に番号をつける

・ベクトル場を描く

・線形回帰, 多項式回帰

・Bluetooth接続