>> OfflineLearnableFourier Unable to resolve the n...
Created on: December 2, 2025
Answered using GPT-5.1 Thinking by Chat01
Created on: December 2, 2025
Answered using GPT-5.1 Thinking by Chat01
OfflineLearnableFourier
Unable to resolve the name 'py.gd.gd'.
Error in gd_call (line 17)
output = py.gd.gd(x_cat_python, mode, N_beams(stage), weights_python, 100);
Error in OfflineLearnableFourier (line 25)
[adjusted_weights, T_N] = gd_call(H, mode, [16]); rng(42)
prior_channel = load('prior_channels.mat').prior_channel;
mean_power = mean(abs(prior_channel).^2, [2,3]);
normalized_channels = prior_channel ./sqrt( mean_power);
clear prior_channel mean_power
H = permute(normalized_channels, [2,3,1]);% [64, L, N_channels]
H = H(:,:,randperm(6000));
clear normalized_channels
% N_scens = 6000;
H = H(:,:,1:200);
N_scens = 200;
N_rx = 64;
N_sc = 192;
Group_size = 1;
SRS_N_ports = 16;
mode = 2;
use_gd = 1;
if use_gd
H = permute(reshape(H, [N_rx, N_sc*Group_size, N_scens/Group_size]), [3, 1, 2]);
[adjusted_weights, T_N] = gd_call(H, mode, [16]);
save("WeightsGD_mode"+num2str(mode)+"_ungrouped.mat", 'adjusted_weights', 'T_N');
else
fourier_weights = get_weights(N_rx, 0);
weights = get_weights_to_train(N_rx, mode, fourier_weights);
LB = zeros(size(weights));
UB = ones(size(weights)) * 2 * pi;
N_optim_params=length(UB);
text% adjusted_weights = load("weights_1scen.mat").adjusted_weights; N_epochs = 50; options = optimoptions(@ga,'MutationFcn',@mutationadaptfeasible,'MaxGenerations',N_epochs,'InitialPopulationMatrix',weights); options = optimoptions(options,'Display','iter'); %'PlotFcn',@gaplotbestf, options.PopulationSize=15*N_optim_params; adjusted_weights = ga( @(coef) (learning_offline(H, mode, N_rx, SRS_N_ports, coef)), N_optim_params , [],[],[],[], LB,UB, [], options) ; P = load("Permutations").P; combined_weights = combine_weights(N_rx, mode, adjusted_weights); T_N = unitary_from_weights(N_rx, P, combined_weights); save("Weights32_mode"+num2str(mode)+".mat", 'adjusted_weights', 'T_N')
end
% exit()
function [weights, T_N] = gd_call(x_cat, mode, N_beams)
import py.numpy.array
if count(py.sys.path,'./New_training') == 0
insert(py.sys.path,int32(0),'./New_training');
end
x_cat_real = py.numpy.array(real(x_cat));
x_cat_imag = py.numpy.array(imag(x_cat));
x_cat_python = x_cat_real + 1i * x_cat_imag;
% tic;
% output = py.gd.gd(x_cat_python, mode, N_beams(1), 0);
% [weights_python, T_N_python] ;
weights_python = 0;
for stage = 1:numel(N_beams)
output = py.gd.gd(x_cat_python, mode, N_beams(stage), weights_python, 100);
% adjusted_weights_combined = combine_weights(N_rx, mode, adjusted_weights);
% T_N = unitary_from_weights(N_rx, adjusted_weights_combined);
[weights_python, T_N_python] = pyrun("weights_python, T_N_python = output", ["weights_python", "T_N_python"], output = output);
% weights_python = double(weights_python);
% T_N_python = double(T_N_python);
end
% toc
weights = double(py.numpy.array(weights_python.real)) +...
1idouble(py.numpy.array(weights_python.imag));
T_N = double(py.numpy.array(T_N_python.real)) +...
1idouble(py.numpy.array(T_N_python.imag));