<jupyter_start><jupyter_text>Réseaux de neurones unrolled pour l'IRM Les lignes suivantes permettent d'installer une bibliothèque pour le calcul de la Transformée de Fourier Non-Uniforme (NUFFT).<jupyter_code>!git clone https://github.com/albangossard/Bindings-NUFFT-pytorch
![ -e nufftbindings/ ] && rm -r -f nufftbindings/
!mv Bindings-NUFFT-pytorch/nufftbindings/ ./
!rm -r -f Bindings-NUFFT-pytorch/<jupyter_output><empty_output><jupyter_text>Téléchargement des données<jupyter_code>!pip install gdown
!gdown https://drive.google.com/uc?id=17k1CYZ4bgbv6q4T4q_zSmEFhwcWlDSVZ
!tar -xzf fastMRI.tar.gz
!rm -r -f data/fastMRI/
!mv fastMRI/ data/fastMRI/
!rm fastMRI.tar.gz<jupyter_output><empty_output><jupyter_text>Imports<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import torch
from tqdm import tqdm
import torch.nn as nn
from torch.utils.tensorboard import SummaryWriter
# from tensorboardX import SummaryWriter

from DIDN import DIDN
import nufftbindings.kbnufft as nufft
import dataLoaderfastMRI
import scripts.metrics as metrics
from scripts.recon import cg
nx = ny = 320
Nbatch = 8

device = torch.device('cuda:0')

xi = torch.tensor(np.load("data/xi_10.npy")).to(device)
print(xi.shape, xi.dtype)
K = xi.shape[0]

nufft.nufft.set_dims(K, (nx, ny), device, Nb=Nbatch)

nufft.nufft.precompute(xi)
dataset_train = dataLoaderfastMRI.fastMRIdatasetKnee(train=True)
dataset_test = dataLoaderfastMRI.fastMRIdatasetKnee(train=False)
train_loader = torch.utils.data.DataLoader(dataset_train, batch_size=Nbatch, shuffle=True)
test_loader = torch.utils.data.DataLoader(dataset_test, batch_size=Nbatch, shuffle=True)
print('nb images in training dataset:',len(dataset_train))
print('nb images in testing dataset:',len(dataset_test))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10792580101180438, 'fraction_numerical': 0.008431703204047217, 'mean_word_length': 6.77292576419214, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '384014', 'license': 'MIT', 'n_tokens_mistral': 698, 'n_tokens_neox': 684, 'n_words': 139, 'path': 'MRI.ipynb', 'repo_name': 'albangossard/Course-inverse-problems-and-unrolled-networks', 'size': '1779'}