Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ plot_style.txt
plotting
Figures
src/__pycache__
data
data
.venv/
.idea/
24 changes: 12 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
dt_string_for_save = now.strftime("%d_%m_%Y_%H_%M")
# Operations commands
commands = {
"SAVE_TO_FILE": True, # Saving results to file or present them over CMD
"CREATE_DATA": False, # Creating new dataset
"LOAD_DATA": True, # Loading data from exist dataset
"LOAD_MODEL": True, # Load specific model for training
"SAVE_TO_FILE": False, # Saving results to file or present them over CMD
"CREATE_DATA": True, # Creating new dataset
"LOAD_DATA": False, # Loading data from exist dataset
"LOAD_MODEL": False, # Load specific model for training
"TRAIN_MODEL": True, # Applying training operation
"SAVE_MODEL": False, # Saving tuned model
"EVALUATE_MODE": True, # Evaluating desired algorithms
Expand All @@ -78,13 +78,13 @@
system_model_params = (
SystemModelParams()
.set_parameter("N", 8)
.set_parameter("M", 3)
.set_parameter("T", 200)
.set_parameter("M", 2)
.set_parameter("T", 100)
.set_parameter("snr", 10)
.set_parameter("signal_type", "NarrowBand")
.set_parameter("signal_nature", "non-coherent")
.set_parameter("eta", 0)
.set_parameter("bias", 0.05)
.set_parameter("bias", 0.0)
.set_parameter("sv_noise_var", 0)
)
# Generate model configuration
Expand All @@ -96,8 +96,8 @@
.set_model(system_model_params)
)
# Define samples size
samples_size = 100000 # Overall dateset size
train_test_ratio = 0.05 # training and testing datasets ratio
samples_size = 1024 # Overall dateset size
train_test_ratio = .1 # training and testing datasets ratio
# Sets simulation filename
simulation_filename = get_simulation_filename(
system_model_params=system_model_params, model_config=model_config
Expand Down Expand Up @@ -160,10 +160,10 @@
# Assign the training parameters object
simulation_parameters = (
TrainingParams()
.set_batch_size(2048)
.set_epochs(80)
.set_batch_size(16)
.set_epochs(20)
.set_model(model=model_config)
.set_optimizer(optimizer="Adam", learning_rate=0.00001, weight_decay=1e-9)
.set_optimizer(optimizer="Adam", learning_rate=0.001, weight_decay=1e-9)
.set_training_dataset(train_dataset)
.set_schedular(step_size=80, gamma=0.2)
.set_criterion()
Expand Down
4 changes: 2 additions & 2 deletions src/data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ def autocorrelation_matrix(X: torch.Tensor, lag: int):

"""
Rx_lag = torch.zeros(X.shape[0], X.shape[0], dtype=torch.complex128).to(device)
meu = torch.mean(X, dim=-1, keepdim=False).to(device).unsqueeze(-1)
for t in range(X.shape[1] - lag):
# meu = torch.mean(X,1)
x1 = torch.unsqueeze(X[:, t], 1).to(device)
x2 = torch.t(torch.unsqueeze(torch.conj(X[:, t + lag]), 1)).to(device)
Rx_lag += torch.matmul(x1 - torch.mean(X), x2 - torch.mean(X)).to(device)
Rx_lag += torch.matmul(x1 - meu, x2 - meu.transpose(0,1)).to(device)
Rx_lag = Rx_lag / (X.shape[-1] - lag)
Rx_lag = torch.cat((torch.real(Rx_lag), torch.imag(Rx_lag)), 0)
return Rx_lag
Expand Down
8 changes: 4 additions & 4 deletions src/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,14 @@ def add_random_predictions(M: int, predictions: np.ndarray, algorithm: str):


def evaluate(
model: nn.Module,
model_type: str,
model_test_dataset: list,
generic_test_dataset: list,
criterion: nn.Module,
subspace_criterion,
system_model,
figures: dict,
model: nn.Module = None,
plot_spec: bool = True,
augmented_methods: list = None,
subspace_methods: list = None,
Expand Down Expand Up @@ -402,16 +402,16 @@ def evaluate(
if not isinstance(augmented_methods, list) and model_type.startswith("SubspaceNet"):
augmented_methods = [
# "mvdr",
"r-music",
"esprit",
# "r-music",
# "esprit",
# "music",
]
# Set default model-based subspace methods
if not isinstance(subspace_methods, list):
subspace_methods = [
"esprit",
# "music",
"r-music",
# "r-music",
# "mvdr",
# "sps-r-music",
# "sps-esprit",
Expand Down
4 changes: 2 additions & 2 deletions src/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ def root_music(Rz: torch.Tensor, M: int, batch_size: int):
for iter in range(batch_size):
R = Bs_Rz[iter]
# Extract eigenvalues and eigenvectors using EVD
eigenvalues, eigenvectors = torch.linalg.eig(R)
eigenvalues, eigenvectors = torch.linalg.eigh(R)
# Assign noise subspace as the eigenvectors associated with M greatest eigenvalues
Un = eigenvectors[:, torch.argsort(torch.abs(eigenvalues)).flip(0)][:, M:]
# Generate hermitian noise subspace matrix
Expand Down Expand Up @@ -774,7 +774,7 @@ def esprit(Rz: torch.Tensor, M: int, batch_size: int):
for iter in range(batch_size):
R = Bs_Rz[iter]
# Extract eigenvalues and eigenvectors using EVD
eigenvalues, eigenvectors = torch.linalg.eig(R)
eigenvalues, eigenvectors = torch.linalg.eigh(R)

# Get signal subspace
Us = eigenvectors[:, torch.argsort(torch.abs(eigenvalues)).flip(0)][:, :M]
Expand Down
2 changes: 1 addition & 1 deletion src/system_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def steering_vec(
)
# If calculation is applied through method (array mismatches are not known).
else:
mis_distance, mis_geometry_noise = 0, 0
mis_distance, mis_geometry_noise, uniform_bias = 0, 0, 0

return (
np.exp(
Expand Down