Code
Code
import numpy as np
# Simulate datasets
np.random.seed(0)
# Processing Methods
if method == 'modulus':
else:
# Normalization
def normalize(data):
# Example usage
# Visualization of a sample
plt.colorbar()
plt.show()
Output :
import numpy as np
# Simulate datasets
np.random.seed(0)
# Processing Methods
if method == 'modulus':
# Normalization
def normalize(data):
# Example usage
# Visualization of a sample
plt.colorbar()
plt.show()
class CNN_numpy:
def __init__(self):
pass
x = x.reshape(x.shape[0], -1)
return x
class PowerFNN_numpy:
def __init__(self):
pass
x = x @ np.random.randn(64, 2)
return x
cnn_model = CNN_numpy()
powerfnn_model = PowerFNN_numpy()
# Simulate input for CNN (batch size 10, channels 1, 30, 30)
cnn_output = cnn_model.forward(cnn_input)
powerfnn_input = np.random.randn(10, 1)
powerfnn_output = powerfnn_model.forward(powerfnn_input)
Output:
import numpy as np
# Simulate datasets
np.random.seed(0)
# Processing Methods
if method == 'modulus':
else:
# Normalization
def normalize(data):
# Example usage
# Visualization of a sample
plt.colorbar()
plt.show()
class CNN_numpy:
def __init__(self):
pass
x = x.mean(axis=(2, 3))
x = x.reshape(x.shape[0], -1)
return x
class PowerFNN_numpy:
def __init__(self):
pass
x = x @ np.random.randn(64, 2)
return x
best_acc = 0
outputs = model.forward(inputs)
one_hot = np.eye(2)[labels]
# Validation step
correct, total = 0, 0
outputs = model.forward(inputs)
preds = np.argmax(outputs, axis=1)
total += len(labels)
best_acc = acc
return best_acc
cnn_model = CNN_numpy()
powerfnn_model = PowerFNN_numpy()
# Simulate input for CNN (batch size 10, channels 1, 30, 30)
cnn_output = cnn_model.forward(cnn_input)
powerfnn_input = np.random.randn(10, 1)
powerfnn_output = powerfnn_model.forward(powerfnn_input)
# Example training
Output :
CNN output shape: (10, 2)
4. Evaluation Metrics
import numpy as np
# Simulate datasets
np.random.seed(0)
# Processing Methods
if method == 'modulus':
else:
# Normalization
def normalize(data):
# Example usage
# Visualization of a sample
plt.colorbar()
plt.show()
class CNN_numpy:
def __init__(self):
pass
def forward(self, x):
x = x.mean(axis=(2, 3))
x = x.reshape(x.shape[0], -1)
return x
class PowerFNN_numpy:
def __init__(self):
pass
x = x @ np.random.randn(64, 2)
return x
best_acc = 0
outputs = model.forward(inputs)
one_hot = np.eye(2)[labels]
# Validation step
correct, total = 0, 0
outputs = model.forward(inputs)
total += len(labels)
best_acc = acc
return best_acc
cnn_model = CNN_numpy()
powerfnn_model = PowerFNN_numpy()
# Simulate input for CNN (batch size 10, channels 1, 30, 30)
cnn_output = cnn_model.forward(cnn_input)
powerfnn_input = np.random.randn(10, 1)
powerfnn_output = powerfnn_model.forward(powerfnn_input)
plt.figure(figsize=(10,6))
los_sorted = np.sort(power_los)
nlos_sorted = np.sort(power_nlos)
plt.xlabel('Power')
plt.ylabel('Probability')
plt.legend()
plt.grid()
plt.savefig('power_distribution.png')
plt.show()
power_los = np.random.randn(100) ** 2
power_nlos = np.random.randn(100) ** 2
plot_cdf_ccdf(power_los, power_nlos)
Output:
import numpy as np
# Simulate datasets
np.random.seed(0)
# Processing Methods
if method == 'modulus':
# Normalization
def normalize(data):
# Example usage
# Visualization of a sample
plt.colorbar()
plt.show()
class CNN_numpy:
def __init__(self):
pass
x = x.mean(axis=(2, 3))
x = x.reshape(x.shape[0], -1)
return x
class PowerFNN_numpy:
def __init__(self):
pass
x = x @ np.random.randn(64, 2)
return x
best_acc = 0
outputs = model.forward(inputs)
one_hot = np.eye(2)[labels]
# Validation step
correct, total = 0, 0
outputs = model.forward(inputs)
total += len(labels)
acc = 100 * correct / total
best_acc = acc
return best_acc
# Hyperparameters
BATCH_SIZE = 64
EPOCHS = 15
cnn_model = CNN_numpy()
plt.figure(figsize=(10,6))
los_sorted = np.sort(power_los)
nlos_sorted = np.sort(power_nlos)
plt.xlabel('Power')
plt.ylabel('Probability')
plt.legend()
plt.grid()
plt.savefig('power_distribution.png')
plt.show()
plot_cdf_ccdf(power_los, power_nlos)
valid_power_norm = valid_power.flatten()
accuracies = []
for th in thresholds:
accuracies.append(acc)
best_th = thresholds[np.argmax(accuracies)]
Output: