Submitted:
01 July 2025
Posted:
14 July 2025
You are already at the latest version
Abstract
Keywords:
1. Introduction
2. Method Design
3. Experimental Design
| import torch import torch.nn as nn import torch.optim as optim import torchvision import torchvision.transforms as transforms import torch.nn.functional as F import time from torch.utils.data import Subset, DataLoader from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, roc_auc_score import numpy as np |
|
# Device device = torch.device("cuda" if torch.cuda.is_available() else "cpu") |
|
# ============================ # Data Preparation (500 Train / 500 Test) # ============================ transform = transforms.Compose([ transforms.ToTensor(), transforms.Normalize((0.5,), (0.5,)) ]) |
|
train_set = torchvision.datasets.CIFAR10(root='./data', train=True, download=True, transform=transform) test_set = torchvision.datasets.CIFAR10(root='./data', train=False, download=True, transform=transform) |
|
train_loader = DataLoader(Subset(train_set, range(500)), batch_size=64, shuffle=True) test_loader = DataLoader(Subset(test_set, range(500)), batch_size=64, shuffle=False) |
|
# ============================ # Baseline MLP with BatchNorm # ============================ class BaselineMLP(nn.Module): def __init__(self): super(BaselineMLP, self).__init__() self.fc1 = nn.Linear(3 * 32 * 32, 512) self.bn1 = nn.BatchNorm1d(512) self.fc2 = nn.Linear(512, 256) self.bn2 = nn.BatchNorm1d(256) self.fc3 = nn.Linear(256, 10) |
|
def forward(self, x): x = x.view(x.size(0), -1) x = F.relu(self.bn1(self.fc1(x))) x = F.relu(self.bn2(self.fc2(x))) return self.fc3(x) |
|
# ========================================= # Harsanyi-inspired BatchNorm-enhanced MLP # ========================================= class HarsanyiBatchNorm1d(nn.Module): def __init__(self, num_features): super(HarsanyiBatchNorm1d, self).__init__() self.bn = nn.BatchNorm1d(num_features) self.attn = nn.Sequential( nn.Linear(num_features, num_features), nn.Sigmoid() ) |
|
def forward(self, x): bn_out = self.bn(x) attn_weights = self.attn(x) return bn_out * attn_weights |
|
class HarsanyiBNMLP(nn.Module): def __init__(self): super(HarsanyiBNMLP, self).__init__() self.fc1 = nn.Linear(3 * 32 * 32, 512) self.hbn1 = HarsanyiBatchNorm1d(512) self.fc2 = nn.Linear(512, 256) self.hbn2 = HarsanyiBatchNorm1d(256) self.fc3 = nn.Linear(256, 10) |
|
def forward(self, x): x = x.view(x.size(0), -1) x = F.relu(self.hbn1(self.fc1(x))) x = F.relu(self.hbn2(self.fc2(x))) return self.fc3(x) |
|
# ============================ # Training & Evaluation Utils # ============================ def train_model(model, loader, optimizer, criterion): model.train() for images, labels in loader: images, labels = images.to(device), labels.to(device) optimizer.zero_grad() outputs = model(images) loss = criterion(outputs, labels) loss.backward() optimizer.step() |
|
def evaluate_model(model, loader): model.eval() preds, targets = [], [] with torch.no_grad(): for images, labels in loader: images = images.to(device) outputs = model(images) preds.append(outputs.cpu()) targets.append(labels) preds = torch.cat(preds).argmax(dim=1).numpy() targets = torch.cat(targets).numpy() one_hot_preds = F.one_hot(torch.tensor(preds), num_classes=10).numpy() |
|
return { 'Accuracy': accuracy_score(targets, preds), 'Precision': precision_score(targets, preds, average='macro', zero_division=0), 'Recall': recall_score(targets, preds, average='macro', zero_division=0), 'F1': f1_score(targets, preds, average='macro', zero_division=0), 'AUROC': roc_auc_score(targets, one_hot_preds, average='macro', multi_class='ovr') } |
|
# ============================ # Run 10 Experiments & Aggregate # ============================ def run_multiple_experiments(model_class, name, runs=10): print(f"\n=== Running: {name} for {runs} runs ===") all_metrics = {k: [] for k in ['Accuracy', 'Precision', 'Recall', 'F1', 'AUROC']} train_times, eval_times = [], [] |
|
for i in range(runs): print(f"\n--- Run {i+1} ---") model = model_class().to(device) optimizer = optim.Adam(model.parameters(), lr=0.001) criterion = nn.CrossEntropyLoss() |
|
start_train = time.time() for epoch in range(3): # short training for speed train_model(model, train_loader, optimizer, criterion) end_train = time.time() |
|
start_eval = time.time() metrics = evaluate_model(model, test_loader) end_eval = time.time() |
|
train_time = end_train - start_train eval_time = end_eval - start_eval train_times.append(train_time) eval_times.append(eval_time) |
|
for k, v in metrics.items(): all_metrics[k].append(v) print(f"[{name}][Run {i+1}] {k}: {v:.4f}") |
|
print(f"[{name}][Run {i+1}] Training Time: {train_time:.2f}s") print(f"[{name}][Run {i+1}] Inference Time: {eval_time:.2f}s") |
|
print(f"\n=== Final Results for {name} ===") for k in all_metrics: mean_val = np.mean(all_metrics[k]) std_val = np.std(all_metrics[k]) print(f"[{name}] {k}: {mean_val:.4f} ± {std_val:.4f}") |
|
print(f"[{name}] Avg Training Time: {np.mean(train_times):.2f}s ± {np.std(train_times):.2f}s") print(f"[{name}] Avg Inference Time: {np.mean(eval_times):.2f}s ± {np.std(eval_times):.2f}s") |
|
# ============================ # Run All # ============================ run_multiple_experiments(BaselineMLP, "Baseline MLP") run_multiple_experiments(HarsanyiBNMLP, "Harsanyi-BN MLP") |
4. Experimental Results and Analysis
- === Final Results for Baseline MLP ===
- [Baseline MLP] Accuracy: 0.3016 ± 0.0095
- [Baseline MLP] Precision: 0.2811 ± 0.0097
- [Baseline MLP] Recall: 0.2926 ± 0.0083
- [Baseline MLP] F1: 0.2772 ± 0.0086
- [Baseline MLP] AUROC: 0.6074 ± 0.0047
- [Baseline MLP] Avg Training Time: 0.71s ± 0.06s
- [Baseline MLP] Avg Inference Time: 0.16s ± 0.02s
- === Final Results for Harsanyi-BN MLP ===
- [Harsanyi-BN MLP] Accuracy: 0.3088 ± 0.0130
- [Harsanyi-BN MLP] Precision: 0.2865 ± 0.0167
- [Harsanyi-BN MLP] Recall: 0.2988 ± 0.0125
- [Harsanyi-BN MLP] F1: 0.2756 ± 0.0145
- [Harsanyi-BN MLP] AUROC: 0.6109 ± 0.0070
- [Harsanyi-BN MLP] Avg Training Time: 1.05s ± 0.10s
- [Harsanyi-BN MLP] Avg Inference Time: 0.19s ± 0.03s
5. Generality and Scalability
6. Conclusion
References
- Rahman, T.; Islam, M.S. MRI brain tumor detection and classification using parallel deep convolutional neural networks. Measurement: Sensors 2023, 26, 100694. [Google Scholar] [CrossRef]
- Halbouni, A.; Gunawan, T.S.; Habaebi, M.H.; Halbouni, M.; Kartiwi, M.; Ahmad, R. CNN-LSTM: Hybrid deep neural network for network intrusion detection system. IEEE Access 2022, 10, 99837–99849. [Google Scholar] [CrossRef]
- Zhao, X.; Wang, L.; Zhang, Y.; Han, X.; Deveci, M.; Parmar, M. A review of convolutional neural networks in computer vision. Artificial Intelligence Review 2024, 57, 99. [Google Scholar] [CrossRef]
- Duan, C.; Ding, J.; Chen, S.; Yu, Z.; Huang, T. Temporal effective batch normalization in spiking neural networks. Advances in Neural Information Processing Systems 2022, 35, 34377–34390. [Google Scholar]
- Dubey, V.; Katarya, R. (2021). BNDNN: Batch Normalization Based Deep Neural Network for Predicting Flood in Urban Areas.
- Kim, Y.; Panda, P. Revisiting batch normalization for training low-latency deep spiking neural networks from scratch. Frontiers in neuroscience 2021, 15, 773954. [Google Scholar] [CrossRef]
- Gao, S.H.; Han, Q.; Li, D.; Cheng, M.M.; Peng, P. Representative batch normalization with feature calibration. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition (pp. 8669–8679). 2021. [Google Scholar]
- Benz, P.; Zhang, C.; Karjauv, A.; Kweon, I.S. (2021). Revisiting batch normalization for improving corruption robustness. In Proceedings of the IEEE/CVF winter conference on applications of computer vision (pp. 494–503).
- Lubana, E.S.; Dick, R.; Tanaka, H. Beyond batchnorm: Towards a unified understanding of normalization in deep learning. Advances in Neural Information Processing Systems 2021, 34, 4778–4791. [Google Scholar]
- Muhammad, A.; Shamshad, F.; Bae, S.H. Adversarial attacks and batch normalization: A batch statistics perspective. IEEE Access 2023, 11, 96449–96459. [Google Scholar] [CrossRef]
- Kim, Y.; Panda, P. Optimizing deeper spiking neural networks for dynamic vision sensing. Neural Networks 2021, 144, 686–698. [Google Scholar] [CrossRef]
- Zhang, Q.; Xiao, J.; Tian, C.; Chun-Wei Lin, J.; Zhang, S. A robust deformed convolutional neural network (CNN) for image denoising. CAAI Transactions on Intelligence Technology 2023, 8, 331–342. [Google Scholar] [CrossRef]
- Musallam, A.S.; Sherif, A.S.; Hussein, M.K. A new convolutional neural network architecture for automatic detection of brain tumors in magnetic resonance imaging images. IEEE access 2022, 10, 2775–2782. [Google Scholar] [CrossRef]
- Dursun, G.; Tandale, S.B.; Gulakala, R.; Eschweiler, J.; Tohidnezhad, M.; Markert, B.; Stoffel, M. Development of convolutional neural networks for recognition of tenogenic differentiation based on cellular morphology. Computer Methods and Programs in Biomedicine 2021, 208, 106279. [Google Scholar] [CrossRef] [PubMed]
- Tang, S.; Zhu, Y.; Yuan, S. Intelligent fault identification of hydraulic pump using deep adaptive normalized CNN and synchrosqueezed wavelet transform. Reliability Engineering & System Safety 2022, 224, 108560. [Google Scholar] [CrossRef]
- Zheng, H.; Wu, Y.; Deng, L.; Hu, Y.; Li, G. (2021, May). In Going deeper with directly-trained larger spiking neural networks. In Proceedings of the AAAI conference on artificial intelligence (Vol. 35, No. 12; pp. 11062–11070.
- Huang, Z.; Lu, W.J.; Hong, C.; Ding, J. (2022). Cheetah: Lean and fast secure {Two-Party} deep neural network inference. In 31st USENIX Security Symposium (USENIX Security 22) (pp. 809–826).
- Szepesi, P.; Szilágyi, L. Detection of pneumonia using convolutional neural networks and deep learning. Biocybernetics and biomedical engineering 2022, 42, 1012–1022. [Google Scholar] [CrossRef]
- Ghaderizadeh, S.; Abbasi-Moghadam, D.; Sharifi, A.; Zhao, N.; Tariq, A. Hyperspectral image classification using a hybrid 3D-2D convolutional neural networks. IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing 2021, 14, 7570–7588. [Google Scholar] [CrossRef]
- Li, W.; Tang, Y.M.; Yu, K.M.; To, S. SLC-GAN: An automated myocardial infarction detection model based on generative adversarial networks and convolutional neural networks with single-lead electrocardiogram synthesis. Information Sciences 2022, 589, 738–750. [Google Scholar] [CrossRef]
- Ergen, T.; Pilanci, M. (2021, July). Revealing the structure of deep neural networks via convex duality. In International Conference on Machine Learning (pp. 3004–3014). PMLR.
- Fdez, J.; Guttenberg, N.; Witkowski, O.; Pasquali, A. Cross-subject EEG-based emotion recognition through neural networks with stratified normalization. Frontiers in neuroscience 2021, 15, 626277. [Google Scholar] [CrossRef]
- Pomazan, V.; Tvoroshenko, I.; Gorokhovatskyi, V. (2023). Development of an application for recognizing emotions using convolutional neural networks.
- Wang, K.; Abid, M.A.; Rasheed, A.; Crossa, J.; Hearne, S.; Li, H. DNNGP, a deep neural network-based method for genomic prediction using multi-omics data in plants. Molecular Plant 2023, 16, 279–293. [Google Scholar] [CrossRef]
- Fang, Z.; Wang, Y.; Peng, L.; Hong, H. Predicting flood susceptibility using LSTM neural networks. Journal of Hydrology 2021, 594, 125734. [Google Scholar] [CrossRef]
- Al-Smadi, M.; Hammad, M.; Baker, Q.B.; Al-Zboon, S.A. A. A transfer learning with deep neural network approach for diabetic retinopathy classification. International Journal of Electrical and Computer Engineering 2021, 11, 3492. [Google Scholar] [CrossRef]
- Saeedi, S.; Rezayi, S.; Keshavarz, H.; R. Niakan Kalhori, S. MRI-based brain tumor detection using convolutional deep learning methods and chosen machine learning techniques. BMC Medical Informatics and Decision Making 2023, 23, 16. [Google Scholar] [CrossRef]
- Yuan, H.; Kelley, D.R. scBasset: Sequence-based modeling of single-cell ATAC-seq using convolutional neural networks. Nature Methods 2022, 19, 1088–1096. [Google Scholar] [CrossRef] [PubMed]
- Karni, E.; Weymark, J.A. Impartiality and relative utilitarianism. Social Choice and Welfare 2024, 63, 1–18. [Google Scholar] [CrossRef]
- Nebel, J.M. Aggregation without interpersonal comparisons of well-being. Philosophy and Phenomenological Research 2022, 105, 18–41. [Google Scholar] [CrossRef]
- Billot, A.; Qu, X. Utilitarian aggregation with heterogeneous beliefs. American Economic Journal: Microeconomics 2021, 13, 112–123. [Google Scholar] [CrossRef]
- Pitis, S. Consistent aggregation of objectives with diverse time preferences requires non-markovian rewards. Advances in Neural Information Processing Systems 2023, 36, 2877–2893. [Google Scholar]
- Pivato, M.; Tchouante, É.F. Bayesian social aggregation with almost-objective uncertainty. Theoretical Economics 2024, 19, 1351–1398. [Google Scholar] [CrossRef]
- Zhi-Xuan, T.; Carroll, M.; Franklin, M.; Ashton, H. Beyond preferences in ai alignment. Philosophical Studies 2024, 1–51. [Google Scholar] [CrossRef]
- Peres, R.Á. The Harsanyi-Rawls Debate: Political philosophy as decision theory under uncertainty. Manuscrito 2021, 44, 89–127. [Google Scholar] [CrossRef]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).