chainer.functions.pad_sequence

chainer.functions.pad_sequenceのサンプル


import chainer.functions as F
import chainer 
import numpy as np

a=chainer.Variable(np.array([[1],[2],[3]],dtype=np.float32))
b=chainer.Variable(np.array([[11],[12]],dtype=np.float32))
c=chainer.Variable(np.array([[21]],dtype=np.float32))

tpl=(a,b,c)
F.pad_sequence(tpl)

variable([[[ 1.],
           [ 2.],
           [ 3.]],

          [[11.],
           [12.],
           [ 0.]],

          [[21.],
           [ 0.],
           [ 0.]]])