pymc.distributions.shape_utils.change_dist_size#

pymc.distributions.shape_utils.change_dist_size(dist, new_size, expand=False)[源代码]#

更改或扩展一个发行版的大小。

参数:
dist:

要调整大小的旧分区。

new_size:

发行版的新大小。

expand: bool, 可选

如果为真,new_size 将被添加到现有分布 size 的前面,使得最终的尺寸等于 (*new_size, *dist.size)。默认为假。

返回:
A new distribution variable that is equivalent to the original distribution with
the new size. The new distribution will not reuse the old RandomState/Generator
input, so it will be independent from the original distribution.

示例

x = Normal.dist(shape=(2, 3))
new_x = change_dist_size(x, new_size=(5, 3), expand=False)
assert new_x.eval().shape == (5, 3)

new_x = change_dist_size(x, new_size=(5, 3), expand=True)
assert new_x.eval().shape == (5, 3, 2, 3)