Coder Social home page Coder Social logo

utcsilab / score-based-channels Goto Github PK

View Code? Open in Web Editor NEW
59.0 4.0 20.0 23.56 MB

Source code for paper "MIMO Channel Estimation using Score-Based Generative Models", published in IEEE Transactions on Wireless Communications.

License: Other

Python 85.29% MATLAB 14.71%
deep-learning physical-layer

score-based-channels's Introduction

MIMO Channel Estimation using Score-Based (Diffusion) Generative Models

This repository contains source code for MIMO Channel Estimation using Score-Based Generative Models, and contains code for training and testing a score-based generative model on channels from the Clustered Delay Line (CDL) family of models, as well as other algorithms.

Requirements

Python 3.8, 3.9, or 3.10. Tested on Ubuntu 20.04 and 22.04. MATLAB license required to run MATLAB scripts.

Getting Started

After cloning the repository, run the following commands for Python 3.10 (similar for other versions of Python):

  • cd score-based-channels
  • python3.10 -m venv .venv
  • source .venv/bin/activate
  • pip install -r requirements.txt

This will create a self-contained virtual environment in the base directory, activate it, and install all required packages.

Pre-generated Data

Train and validation data for CDL-C channels can be directly downloaded from the command line using the following:

mkdir data
curl -L https://utexas.box.com/shared/static/nmyg5s06r6m2i5u0ykzlhm4vjiqr253m.mat --output ./data/CDL-C_Nt64_Nr16_ULA0.50_seed1234.mat
curl -L https://utexas.box.com/shared/static/2a7tavjo9hk3wyhe9vv0j7s2l6en4mj7.mat --output ./data/CDL-C_Nt64_Nr16_ULA0.50_seed4321.mat

For other channel distributions (CDL-A, CDL-B, CDL-D) shown in the paper the used training and validation data can be downloaded from the following public repository:

https://utexas.box.com/s/f7g7yqdw5w0fea0b59aym3xsvbvw1uch

Once downloaded, place these files in the data folder under the main directory.

Pre-trained Models

A pre-trained diffusion model for CDL-C channels can be directly downloaded from the command line using the following:

mkdir -p models/score/CDL-C
curl -L https://utexas.box.com/shared/static/4nubcpvpuv3gkzfk8dgjo6ay0ssps66w.pt --output ./models/score/CDL-C/final_model.pt

This will create the nested directories models/score/CDL-C and place the weights there. Weights for models trained on other distributions (CDL-A, CDL-B, CDL-D, Mixed) shown in the paper can be downloaded from the following public repository:

https://utexas.box.com/s/m58udx6h0glwxua88zgdwrff87jvy3qw

Once downloaded, places these files in their matching directory structure as final_model.pt.

Training Diffusion Models on MIMO Channels

After downloading the example CDL-C data, a diffusion model can be trained by running:

python train_score.py

The model is trained for 400 epochs by default, and the last model weights will be automatically saved in the model folder under the appropriate structure. To train on other channel distributions, see the --train argument.

Channel Estimation with Diffusion Models

To run channel estimation with the CDL-C data and the pretrained model run:

python test_score.py

This will run channel estimation in the setting of Figure 5c of the paper, and will reproduce the Score-based (CDL-C) curve:

Running the above command will automatically plot and save results in the results/score/train-CDL-C_test-CDL-C folder. To run channel estimation on other channel distributions, see the --train and --test arguments, which dictate what pretrained model should be used and what the test distribution is, respectively.

Hyper-parameter Tuning

Tuning the inference hyper-parameters alpha (the step size in Annealed Langevin Dynamics), beta (a multiplier for the noise added in each step of Annealed Langevin Dynamics), and N (the number of inference steps in Annealed Langevin Dynamics) can be done for the CDL-C pretrained model by running:

python tune_hparams_score.py

This will perform a grid search for the best values of alpha, beta, and N and will save the results in the results/score folder. To modify the searched values and the model that is being tuned, see the alpha_step_range, beta_noise_range, and channel arguments respectively.

Generating Channel Data

For completeness, we also include the Matlab scripts used to generated all training and testing datasets in the matlab folder. The main script to run is matlab/generate_data.m.

Citations

Full credits for the ncsnv2 repository go to: https://github.com/ermongroup/ncsnv2

Please include the following citation when using or referencing this codebase:

@ARTICLE{9957135,
  author={Arvinte, Marius and Tamir, Jonathan I.},
  journal={IEEE Transactions on Wireless Communications}, 
  title={MIMO Channel Estimation Using Score-Based Generative Models}, 
  year={2023},
  volume={22},
  number={6},
  pages={3698-3713},
  doi={10.1109/TWC.2022.3220784}}

Previous related publications are:

@inproceedings{arvinte2022score1,
  title={Score-Based Generative Models for Wireless Channel Modeling and Estimation},
  author={Arvinte, Marius and Tamir, Jonathan},
  booktitle={ICLR Workshop on Deep Generative Models for Highly Structured Data},
  year={2022}
}

@inproceedings{arvinte2022score2,
  title={Score-Based Generative Models for Robust Channel Estimation},
  author={Arvinte, Marius and Tamir, Jonathan I},
  booktitle={2022 IEEE Wireless Communications and Networking Conference (WCNC)},
  pages={453--458},
  year={2022},
  organization={IEEE}
}

score-based-channels's People

Contributors

mariusarvinte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

score-based-channels's Issues

About Lasso

Hi,
I'm interested in the Lasso part, but I didn't find the code for the Lasso part. Can you tell me where the code corresponding to the LASSO part is?
Thank you!

Error during installation

I am encountering the following error. Please advise. I tried it for Python3.12 as well as 3.8.

$ pip install -r requirements.txt .
ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.

aux_models is missing and error with l1_Fourier_lifted

Hi,

I have the following issues:

  1. aux_model in LDAMP doesn't seem to be in the repo

  2. when running l1_fourier_lifted as it, I have the following error:

Traceback (most recent call last):
  File "/home/nicolas/.local/lib/python3.9/site-packages/sigpy/prox.py", line 49, in __call__
    output = self._prox(alpha, input)
  File "/home/nicolas/.local/lib/python3.9/site-packages/sigpy/prox.py", line 276, in _prox
    return thresh.soft_thresh(self.lamda * alpha, input)
  File "/home/nicolas/.local/lib/python3.9/site-packages/sigpy/thresh.py", line 33, in soft_thresh
    return _soft_thresh(lamda, input)
numpy.core._exceptions.UFuncTypeError: ufunc '_soft_thresh' did not contain a loop with signature matching types (<class 'numpy.dtype[float64]'>, <class 'numpy.dtype[complex128]'>) -> <class 'numpy.dtype[complex128]'>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/nicolas/nicolas/MIMO_detection_project/Langevin_joint_symbs_H/score-based-channels/test_l1Fourier_lifted.py", line 183, in <module>
    alg.update()
  File "/home/nicolas/.local/lib/python3.9/site-packages/sigpy/alg.py", line 63, in update
    self._update()
  File "/home/nicolas/.local/lib/python3.9/site-packages/sigpy/alg.py", line 189, in _update
    backend.copyto(self.x, self.proxg(self.alpha, self.x))
  File "/home/nicolas/.local/lib/python3.9/site-packages/sigpy/prox.py", line 52, in __call__
    raise RuntimeError('Exceptions from {}.'.format(self)) from e
RuntimeError: Exceptions from <[256, 64] L1Reg Prox>..

Seems to be related to the lifting parameter, but when changing the values to the size of the channel, or even using lifting 1, I still having the same issue.

Thanks,
Nicolas.

Hyperparameters notation and SNR mismatch

Hi, I have the following two observations:

  1. According to step 3, we need to run the hyper-parameter script to find the beta and N. However, it is not clear what is N: in the paper, it used for the amount of samples in the training process, but it seems that for the hyper-paremeter tunning it corresponds to another thing. Is N denoting the inference steps?

  2. When I run the inference code, I have a mismatch with the SNR: it seems that it is shifted 15dB wrt the results in the paper. Is there something to change?

Thanks in advance!

Differences in Pretrained and Output Models

Hello,

I have a question about the pretrained model provided on this web page, final_model.pt. After running the train_score.py script to obtain the trained model, I noticed some differences between the output model and the one you provided. Specifically, the configuration of the output model I obtained does not include the "sampling" field, which is required for the test_score.py script (e.g., nmse_log: config.sampling.steps_each on line 91). Additionally, there are a few other . For example, the value of config.data.noise_std is 0 in the output model I obtained, whereas it is 0.01 in the pretrained model. I would like to understand the reasons behind these differences.

Thank you.

About getting the received signal val_Y in test_score.py

Hello,

Thanks for the excellent work! I have a question about the way you generate val_Y in the following code:

val_Y = torch.matmul(val_P, val_H)
val_Y = val_Y + \
np.sqrt(local_noise) * torch.randn_like(val_Y)

I'm wondering whether it should be np.sqrt(local_noise/2) in L122 instead since local_noise is the variance of complex-valued noise. Should the standard deviation of the real and imaginary parts be $\sigma_{\text{pilot}}/\sqrt{2}$, as shown in test_ml.py:

val_Y = np.matmul(val_P, val_H)
val_Y = val_Y + \
np.sqrt(local_noise) / np.sqrt(2.) * \
(np.random.normal(size=val_Y.shape) + \
1j * np.random.normal(size=val_Y.shape))

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.