コード例 #1
0
def eager_binomial(total_count, probs, value):
    probs = torch_stack((1 - probs, probs))
    value = torch_stack((total_count - value, value))
    return Multinomial(total_count, probs, value=value)
コード例 #2
0
ファイル: test_torch.py プロジェクト: lawrencechen0921/funsor
def test_torch_stack(n, shape, dim):
    tensors = [torch.randn(shape) for _ in range(n)]
    actual = torch_stack(tuple(Tensor(t) for t in tensors), dim=dim)
    expected = Tensor(torch.stack(tensors, dim=dim))
    assert_close(actual, expected)
コード例 #3
0
def eager_beta(concentration1, concentration0, value):
    concentration = torch_stack((concentration0, concentration1))
    value = torch_stack((1 - value, value))
    return Dirichlet(concentration, value=value)