chainer.functions.broadcast(*args)[source]

与えられた変数をブロードキャストする。

(訳注:numpyではブロードキャストを適宜してくれるが、Chainerでは明示的にしなければいけない)

 

Parameters: args (Variable or numpy.ndarray or cupy.ndarray) –ブロードキャストされる入力値。入力値の各次元のshapeは同じサイズでなければならない。
Returns: 入力された引数からブロードキャストされたVariable または  Variable オブジェクトのタプル。
Return type: Variable

 

Example

 


>>>
x = np.random.uniform(0, 1, (3, 2)).astype('f')
>>> y = F.broadcast(x)
>>> np.all(x == y.data)
True
>>> z = np.random.uniform(0, 1, (3, 2)).astype('f')
>>> y, w = F.broadcast(x, z)
>>> np.all(x == y.data) & np.all(z == w.data)
True