This project investigates the Forward-Forward (FF) Algorithm, a novel alternative to Backpropagation (BP) for training neural networks. The key objectives are:
- Extending the FF algorithm to handle complex datasets like CIFAR-10.
- Experimenting with various activation functions, including custom activations (
ReLU_Full_Grad,T-Distribution). - Comparing FF against BP to evaluate performance, stability, and computational efficiency.
- Goodness-based Layer Training: FF trains layers independently by maximizing goodness scores for positive samples and minimizing them for negative samples.
- Custom Activations: Incorporates unique activations tailored for FF.
- Dataset: CIFAR-10, with custom positive, negative, and neutral samples for FF.
- Performance Comparison: Comprehensive analysis of FF and BP algorithms using multiple metrics.
FF/
├── Charts&Results/
│ ├── graphs/ # Plots for results visualization
│ ├── Results/ # Tabular summaries of experiments
├── datasets/
│ ├── cifar-10-batches-py/ # Raw CIFAR-10 data
│ ├── FashionMNIST/ # Fashion MNIST data (optional)
│ ├── cifar-10-python.tar.gz # Compressed CIFAR-10 dataset
├── logs/ # Logs for training/validation/testing
│ ├── experiments/ # Configurations and run-specific outputs
├── outputs/ # Model checkpoints and predictions
├── src/ # Main source code
│ ├── ff_model.py # FF model definition
│ ├── ff_cifar.py # Dataset handling and training loops
│ ├── ff_bp_model.py # Hybrid FF-BP implementation
│ ├── utils.py # Helper utilities
│ ├── main.py # Main execution script for FF
│ ├── main_bp.py # BP-only execution script
├── notebooks/
│ ├── CIFAR_BP.ipynb # Experimentation with BP
│ ├── parse_and_visualize.ipynb # Visualization and metrics parsing
├── config.yaml # Configurations for FF experiments
├── config_bp.yaml # Configurations for BP experiments
├── environment.yml # Conda environment file
├── README.md # Project overview and instructions
git clone [<repository-url>](https://github.com/venkateshtantravahi/ForwardForwardAlgorithm.git)
cd FF
Use the environment.yml file to create a Conda environment:
conda env create -f environment.yml
conda activate FF
The CIFAR-10 dataset will be automatically downloaded when running the scripts for the first time.
To train the model using the Forward-Forward algorithm:
python src/main.py
Hydra configuration will automatically handle the settings from config.yaml.
Logs and results will be stored in the logs/ directory.
To compare FF with Backpropagation:
python src/main_bp.py
To generate and view visualizations from the experimental results:
jupyter notebook notebooks/parse_and_visualize.ipynb
- Goodness-Based Training: FF layers are trained by maximizing the goodness scores for positive samples and minimizing them for negative samples.
- Custom Activations: Includes novel activations like
ReLU_Full_GradandT-Distributionfor FF optimization.
- Standard BP implementation using gradient descent.
- Benchmarked against FF for identical tasks and datasets.
- Performance Trends: FF shows competitive results but lacks BP's overall stability in handling complex datasets like CIFAR-10.
- Activation Comparisons: Detailed analysis of different activation functions across FF and BP.
For detailed results, refer to the
Charts&Results/Resultsdirectory.