How to use the torchkbnufft.math.inner_product function in torchkbnufft

To help you get started, we’ve selected a few torchkbnufft examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mmuckley / torchkbnufft / tests / test_adjoints.py View on Github external
smap=smap,
            im_size=im_size,
            numpoints=numpoints,
            coilpack=True
        ).to(dtype=dtype, device=device)
        adjsensenufft_ob = AdjMriSenseNufft(
            smap=smap,
            im_size=im_size,
            numpoints=numpoints,
            coilpack=True
        ).to(dtype=dtype, device=device)

        x_forw = sensenufft_ob(x, ktraj)
        y_back = adjsensenufft_ob(y, ktraj)

        inprod1 = inner_product(y, x_forw, dim=2)
        inprod2 = inner_product(y_back, x, dim=2)

        assert torch.norm(inprod1 - inprod2) < norm_tol
github mmuckley / torchkbnufft / tests / test_adjoints.py View on Github external
sensenufft_ob = MriSenseNufft(
            smap=smap,
            im_size=im_size,
            numpoints=numpoints
        ).to(dtype=dtype, device=device)
        adjsensenufft_ob = AdjMriSenseNufft(
            smap=smap,
            im_size=im_size,
            numpoints=numpoints
        ).to(dtype=dtype, device=device)

        x_forw = sensenufft_ob(x, ktraj)
        y_back = adjsensenufft_ob(y, ktraj)

        inprod1 = inner_product(y, x_forw, dim=2)
        inprod2 = inner_product(y_back, x, dim=2)

        assert torch.norm(inprod1 - inprod2) < norm_tol
github mmuckley / torchkbnufft / tests / test_sparse_adjoints.py View on Github external
adjkbinterp_ob = KbInterpBack(
            im_size=im_size,
            grid_size=grid_size,
            numpoints=numpoints
        ).to(dtype=dtype, device=device)

        real_mat, imag_mat = precomp_sparse_mats(ktraj, kbinterp_ob)
        interp_mats = {
            'real_interp_mats': real_mat,
            'imag_interp_mats': imag_mat
        }

        x_forw = kbinterp_ob(x, ktraj, interp_mats)
        y_back = adjkbinterp_ob(y, ktraj, interp_mats)

        inprod1 = inner_product(y, x_forw, dim=2)
        inprod2 = inner_product(y_back, x, dim=2)

        assert torch.norm(inprod1 - inprod2) < norm_tol
github mmuckley / torchkbnufft / tests / test_sparse_adjoints.py View on Github external
adjkbnufft_ob = AdjKbNufft(
            im_size=im_size,
            numpoints=numpoints
        ).to(dtype=dtype, device=device)

        real_mat, imag_mat = precomp_sparse_mats(ktraj, kbnufft_ob)
        interp_mats = {
            'real_interp_mats': real_mat,
            'imag_interp_mats': imag_mat
        }

        x_forw = kbnufft_ob(x, ktraj, interp_mats)
        y_back = adjkbnufft_ob(y, ktraj, interp_mats)

        inprod1 = inner_product(y, x_forw, dim=2)
        inprod2 = inner_product(y_back, x, dim=2)

        assert torch.norm(inprod1 - inprod2) < norm_tol
github mmuckley / torchkbnufft / tests / test_adjoints.py View on Github external
kbinterp_ob = KbInterpForw(
            im_size=im_size,
            grid_size=grid_size,
            numpoints=numpoints
        ).to(dtype=dtype, device=device)
        adjkbinterp_ob = KbInterpBack(
            im_size=im_size,
            grid_size=grid_size,
            numpoints=numpoints
        ).to(dtype=dtype, device=device)

        x_forw = kbinterp_ob(x, ktraj)
        y_back = adjkbinterp_ob(y, ktraj)

        inprod1 = inner_product(y, x_forw, dim=2)
        inprod2 = inner_product(y_back, x, dim=2)

        assert torch.norm(inprod1 - inprod2) < norm_tol
github mmuckley / torchkbnufft / tests / test_adjoints.py View on Github external
y = y.detach().to(dtype=dtype, device=device)
        ktraj = ktraj.detach().to(dtype=dtype, device=device)

        kbnufft_ob = KbNufft(
            im_size=im_size,
            numpoints=numpoints
        ).to(dtype=dtype, device=device)
        adjkbnufft_ob = AdjKbNufft(
            im_size=im_size,
            numpoints=numpoints
        ).to(dtype=dtype, device=device)

        x_forw = kbnufft_ob(x, ktraj)
        y_back = adjkbnufft_ob(y, ktraj)

        inprod1 = inner_product(y, x_forw, dim=2)
        inprod2 = inner_product(y_back, x, dim=2)

        assert torch.norm(inprod1 - inprod2) < norm_tol
github mmuckley / torchkbnufft / tests / test_sparse_adjoints.py View on Github external
im_size=im_size,
            numpoints=numpoints,
            coilpack=True
        ).to(dtype=dtype, device=device)

        real_mat, imag_mat = precomp_sparse_mats(ktraj, sensenufft_ob)
        interp_mats = {
            'real_interp_mats': real_mat,
            'imag_interp_mats': imag_mat
        }

        x_forw = sensenufft_ob(x, ktraj, interp_mats)
        y_back = adjsensenufft_ob(y, ktraj, interp_mats)

        inprod1 = inner_product(y, x_forw, dim=2)
        inprod2 = inner_product(y_back, x, dim=2)

        assert torch.norm(inprod1 - inprod2) < norm_tol
github mmuckley / torchkbnufft / tests / test_adjoints.py View on Github external
sensenufft_ob = MriSenseNufft(
            smap=smap,
            im_size=im_size,
            numpoints=numpoints
        ).to(dtype=dtype, device=device)
        adjsensenufft_ob = AdjMriSenseNufft(
            smap=smap,
            im_size=im_size,
            numpoints=numpoints
        ).to(dtype=dtype, device=device)

        x_forw = sensenufft_ob(x, ktraj)
        y_back = adjsensenufft_ob(y, ktraj)

        inprod1 = inner_product(y, x_forw, dim=2)
        inprod2 = inner_product(y_back, x, dim=2)

        assert torch.norm(inprod1 - inprod2) < norm_tol
github mmuckley / torchkbnufft / tests / test_adjoints.py View on Github external
ktraj = ktraj.detach().to(dtype=dtype, device=device)

        kbnufft_ob = KbNufft(
            im_size=im_size,
            numpoints=numpoints
        ).to(dtype=dtype, device=device)
        adjkbnufft_ob = AdjKbNufft(
            im_size=im_size,
            numpoints=numpoints
        ).to(dtype=dtype, device=device)

        x_forw = kbnufft_ob(x, ktraj)
        y_back = adjkbnufft_ob(y, ktraj)

        inprod1 = inner_product(y, x_forw, dim=2)
        inprod2 = inner_product(y_back, x, dim=2)

        assert torch.norm(inprod1 - inprod2) < norm_tol
github mmuckley / torchkbnufft / tests / test_sparse_adjoints.py View on Github external
).to(dtype=dtype, device=device)
        adjkbnufft_ob = AdjKbNufft(
            im_size=im_size,
            numpoints=numpoints
        ).to(dtype=dtype, device=device)

        real_mat, imag_mat = precomp_sparse_mats(ktraj, kbnufft_ob)
        interp_mats = {
            'real_interp_mats': real_mat,
            'imag_interp_mats': imag_mat
        }

        x_forw = kbnufft_ob(x, ktraj, interp_mats)
        y_back = adjkbnufft_ob(y, ktraj, interp_mats)

        inprod1 = inner_product(y, x_forw, dim=2)
        inprod2 = inner_product(y_back, x, dim=2)

        assert torch.norm(inprod1 - inprod2) < norm_tol