padding 幅の引数の与え方がおかしくないでしょうか?
リファレンス numpy.pad を参照ください。
Number of values padded to the edges of each axis. ((before_1, after_1), … (before_N, after_N)) unique pad widths for each axis. ((before, after),) yields same before and after pad for each axis. (pad,) or int is a shortcut for before = after = pad width for all axes.
とあるので、pad_width は以下の4つのいずれかの方法で指定する必要があります。
array を n 次元配列とする。
各軸ごとに前後のパディング幅をそれぞれ指定する。
pad_width=[((before_1, after_1), … (before_N, after_N))]
(before_i, after_i) は axis=i の index=0 側に before_i、index=-1 側に after_i だけパディングすることを意味する。
python
1import numpy as np
2
3a = np.full((3, 3), 10, dtype=int)
4
5b = np.pad(a, [(2, 3), (0, 1)], 'constant')
6print(b)
7# [[ 0 0 0 0]
8# [ 0 0 0 0]
9# [10 10 10 0]
10# [10 10 10 0]
11# [10 10 10 0]
12# [ 0 0 0 0]
13# [ 0 0 0 0]
14# [ 0 0 0 0]]
各軸ごとに前後同じパディング幅を指定する。
pad_width=[(pad_1,), … (pad_N,)]
(pad_i,) は axis=i の index=0 及び index=-1 両方に pad_i だけパディングすることを意味する。
python
1import numpy as np
2
3a = np.full((3, 3), 10, dtype=int)
4b = np.pad(a, [(1,), (2,)], 'constant')
5print(b)
6# [[ 0 0 0 0 0 0 0]
7# [ 0 0 10 10 10 0 0]
8# [ 0 0 10 10 10 0 0]
9# [ 0 0 10 10 10 0 0]
10# [ 0 0 0 0 0 0 0]]
すべての軸一括で前後のパディング幅をそれぞれ指定する。
pad_width=[before, after]
すべての軸に index=0 側に before、index=-1 側に after だけパディングすることを意味する。
python
1import numpy as np
2
3a = np.full((3, 3), 10, dtype=int)
4b = np.pad(a, [1, 2], 'constant')
5print(b)
6# [[ 0 0 0 0 0 0]
7# [ 0 10 10 10 0 0]
8# [ 0 10 10 10 0 0]
9# [ 0 10 10 10 0 0]
10# [ 0 0 0 0 0 0]
11# [ 0 0 0 0 0 0]]
すべての軸一括で前後同じパディング幅を指定する。
すべての軸の index=0 及び index=-1 両方に pad だけパディングすることを意味する。
python
1import numpy as np
2
3a = np.full((3, 3), 10, dtype=int)
4b = np.pad(a, 1, 'constant')
5print(b)
6# [[ 0 0 0 0 0]
7# [ 0 10 10 10 0]
8# [ 0 10 10 10 0]
9# [ 0 10 10 10 0]
10# [ 0 0 0 0 0]]
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。