Example #1
0
def test_maxpool_deriv(workers):
    alice, bob, james = workers["alice"], workers["bob"], workers["james"]
    x = (
        torch.tensor([[10, 0], [15, 7]])
        .share(alice, bob, crypto_provider=james, dtype="long")
        .child
    )
    max_d = maxpool_deriv(x)

    assert (max_d.get() == torch.tensor([[0, 0], [1, 0]])).all()

    # With dtype int
    x = torch.tensor([[10, 0], [15, 7]]).share(alice, bob, crypto_provider=james, dtype="int").child
    max_d = maxpool_deriv(x)

    assert (max_d.get() == torch.tensor([[0, 0], [1, 0]])).all()
Example #2
0
def test_maxpool_deriv(workers):
    alice, bob, james = (
        workers["alice"],
        workers["bob"],
        workers["james"],
    )
    tensorA = (torch.tensor([[0, 1, 8, 3]]).share(alice,
                                                  bob,
                                                  crypto_provider=james,
                                                  dtype="long").child)
    deriv = securenn.maxpool_deriv(tensorA)
    assert (deriv.get() == torch.tensor([[0, 0, 1, 0]])).all()