## DeepMIMO Forum

# [Solved] Learning Beam Codebooks in mmWave/THz MIMO System

Hello,

I downloaded the simulation codes from the link.

To see the example figure, I followed all steps. However I couldnt get the Fig. 7(c).

At step 5 I run the code: **plot_pattern(beams.’)** in Matlab Command Window.

But it gives this error. "Error: The input character is not valid in MATLAB statements or expressions." And no figure window appeared.

When I run this code: **plot_pattern('beams.') **in Matlab Command Window, it gives

Undefined function or variable 'polarplot'.

Error in plot_pattern (line 15)

polarplot(theta_s, proj(:,n).')

Figure window appeared but it was empty.

What can i do to see the Fig. 7(c)? Am I missing something?

Thanks in advance. Regards.

**main.py**, you might check if there is a folder named 'beams' and if there are .mat files in it. The number of .mat files should be equal to the codebook size, as each .mat is essentially a learned beam.

**read_beams.py**to generate "beam_codebook.mat" file and load it back in Matlab. That will give you a variable called 'beams' in the Matlab workspace that is used by plot_pattern function.

Thank you for your detailed explanation Yu.

I now have the Fig.7(c). MATLAB version was the problem.

PS: "**plot_pattern(beams.')**" is the correct command. However, on the website under applications (Codebook Learning RL) section, at step 5, the command is **plot_pattern(beams.’). apostrophe **is different.

I want to plot fig.7(a) as well. How can i get that figure? Any hint would be appreciated.

Thanks again.

I am glad that you reproduced the figure and thank you for pointing out the potential typo on the website.

Regarding your question for generating Fig. 7 (a), you simply need to run the simulation multiple times (i.e., what you have done to generate Fig. 7 (c) corresponds to only one point in Fig. 7 (a)). Specifically, each time before you run the codes, you should change the value of `options['num_NNs']`

in the `main.py`

script to be the codebook size you want. As a result, each time you will get a codebook with its size specified by `options['num_NNs']`

.

After acquiring these learned codebooks, you can test their performance on your user channel dataset. You can refer to Eq. (8) in the paper for the calculation. Along with DFT codebook and the EGC beamforming method, you can finally calculate the average beamforming gain achieved by each one of them and get Fig. 7 (a).

Let me know if this is not clear or you have any other questions.

Best,

Yu

I have confused about how can I test their performance on my user channel dataset. Can you be more specific? Since the code execution time is quite long, It will take almost 1 week to reproduce the codebooks with different **options['num_NNs']** parameters.

**PS**: By the way, your explanation help me get the idea about how to plot figure 9 in the Deep Learning Coordinated Beamforming for Highly-Mobile Millimeter Wave Systems paper.

Thanks again Yu.

Thanks for your reply.

Yes, it will take a long time if you want to get codebooks of different sizes. I am really sorry for causing the inconvenience to you. To shorten the execution time (which of course also heavily depends on the computation platform you have), for instance, I was simply opening multiple sessions (i.e., whatever program you use to run the python scripts) to accelerate the simulation by that time (i.e., different processes execute the learning of different codebook sizes). Another way to make the time shorter could be by changing `options['num_loop']`

and `train_opt['num_iter']`

which basically control the number of iterations of the simulation. Of course, if you make these numbers very small then you will expect a certain level of degradation in the final performance, which is always the tradeoff in these stochastic algorithms. Or similarly, if you observe that the achieved gain is already good enough, then you can just stop the program without waiting till the end. Regarding the calculation of the performance, kindly find the following very easy example code:

M = 64; % M: number of antenna N = 16; % N: codebook size U = 100; % U: number of users Theta = randn(M, N); % The learned phases W = (1/sqrt(M))*exp(1j*Theta); % Beam codebook (output of the simulation) H = randn(M, U) + 1j * randn(M, U); % User channel dataset average_gain = mean(max(abs(W'*H).^2)); % Eq. (8) in the paper

`W`

with either your learned codebook or DFT codebook or EGC codebook (just to make sure that it has a shape of the number of antennas by the number of beams). And replace `H`

with your user channel dataset (similarly, make sure that it has a shape of the number of antennas by the number of users). As I mentioned last time, Eq. (8) in the paper is exactly what I used to calculate such average beamforming gain performance if you want to know more details.
Good luck,

Yu

Leave a reply

Latest Post: Another way for installing DeepMIMO when "pip install DeepMIMO" fails. Our newest member: RickyRix Recent Posts Unread Posts Tags

Forum Icons: Forum contains no unread posts Forum contains unread posts

Topic Icons: Not Replied Replied Active Hot Sticky Unapproved Solved Private Closed