# Filename: PARITY-calculatingNN_Supercoded_V2.0.py
# Description: An advanced, highly configurable PyTorch script to train a neural network on the N-bit parity problem.
#
# Supercoding LLM Recode of PARITY-calculatingNN_Schmidhuber_V1.0.py
#
# This version introduces significant enhancements for robust experimentation and analysis:
# - Full Hyperparameterization: All key parameters are exposed via command-line arguments for easy tuning.
# - Flexible Problem Definition: The concept of "parity" can be switched between 'even', 'odd', or 'majority' rule,
# allowing the network to be tested on different but related logical problems.
# - Advanced Visualization: Generates a suite of high-quality plots (saved to disk and shown in popups) inspired
# by analytical scientific scripts, including:
# - Detailed Training History (Loss & Accuracy)
# - Confusion Matrix Heatmap
# - Prediction Margin Distribution Histogram
# - Raw Output vs. True Label Scatter Plot
…
V0.1 (manually debugged)
The only significant change is fixing the test_size parameter in the two train_test_split calls. I have also added comments to highlight the fix.
The Bug:
In the V0.0 train_test_split function calls, the parameter was set as:
test_size = 1 - VALIDATION_SPLIT
With VALIDATION_SPLIT = 0.2, this meant test_size = 0.8.
This single line caused two major problems:
It inverted the dataset split. Instead of training on 80% of the data and testing on 20%, the model was being trained on a tiny 20% of the data and tested on 80%.
It starved the model. While the "Informed" model is simple and should learn quickly, giving it such a small portion of the data can, with an unlucky random initialization of weights, cause the optimizer to converge to a completely wrong solution (like predicting the opposite class). The extreme learning seen in the loss graph combined with the abysmal accuracy is a classic symptom of this. The model found a "perfect" solution for the tiny training …
Classic Iris (flower) classification based on petal dimensions data csv file. One script uses Random Forest Classifier with graphs of distribution of samples and leaf s.
The NN file is a neural net (variable hyperparameters) for training to perform in inference the same Iris flower classification using the same csv data.
Based on translation from https://github.com/Azacus1/Modelling-for-sin-wave-function/tree/main
https://github.com/Azacus1/Modelling-for-sin-wave-function/blob/main/Model.py
See How to use tensorflow lite to export model to Arduino: https://github.com/Azacus1/Modelling-for-sin-wave-function/tree/main
Intro to TinyML Part 1: Training a Neural Network for Arduino in TensorFlow | Digi-Key Electronics
https://www.youtube.com/watch?v=BzzqYNYOcWc&t=0s
Intro to TinyML Part 2: Deploying a TensorFlow Lite Model to Arduino | Digi-Key Electronics
https://www.youtube.com/watch?v=dU01M61RW8s&t