The Universal Activation Function (UAF) is a unique approach designed to enhance machine learning models, as examined in the notable research by Yuen et al. in their paper published in Scientific Reports. This article will guide you step-by-step on how to set up and run UAF in both TensorFlow and PyTorch environments using Docker.
Prerequisites
- Docker: Ensure you have Docker installed on your machine. You can download it from Docker Installation Guide.
- Git: You’ll need Git to clone the repository. Make sure it’s installed on your system.
Getting the Code
To get started, you’ll need to pull the source code repository. Execute the following command in your terminal:
git clone https://github.com/SensorOrgNet/Universal_Activation_Function.git
Running the TensorFlow 2 Version
Follow these steps to run the UAF using TensorFlow:
- Install the CUDA 11.2 container with the command below:
- Once inside the container, update the package manager and install Python:
- Install TensorFlow and run the MLP with UAF for the MNIST dataset:
docker run --name UAF --gpus all -v home/username/UAF:workspace -w workspace -it nvcr.io/nvidia/cuda:11.2.0-cudnn8-devel-ubuntu20.04 bash
apt update
apt install python3-pip
pip3 install tensorflow==2.7.0
cd Universal_Activation_Function
tensorflow python3 mnist_UAF.py
Running the PyTorch Version
Similarly, here’s how to execute the UAF in a PyTorch setting:
- Install the CUDA 11.3 container:
- Update packages and install Python:
- Install the necessary PyTorch packages:
- Run the CNN with UAF for the MNIST dataset:
- Execute the GCN2 with UAF for the CORA dataset:
- Run the PNA with UAF for the ZNC dataset:
docker run --name UAF --gpus all -v home/username/UAF:workspace -w workspace -it nvcr.io/nvidia/cuda:11.3.0-cudnn8-devel-ubuntu20.04 bash
apt update
apt install python3-pip
pip3 install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio==0.10.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
pip3 install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0+cu113.html
pip3 install torch-sparse -f https://data.pyg.org/whl/torch-1.10.0+cu113.html
pip3 install torch-cluster -f https://data.pyg.org/whl/torch-1.10.0+cu113.html
pip3 install torch-spline-conv -f https://data.pyg.org/whl/torch-1.10.0+cu113.html
pip3 install torch-geometric
cd Universal_Activation_Function
pytorch python3 mnist_UAF.py
cd Universal_Activation_Function
pytorch python3 gcn2_cora_UAF.py 0
cd Universal_Activation_Function
pytorch python3 pna_UAF.py 0
Understanding the Code through Analogy
Think of the Universal Activation Function like a Swiss Army knife for your machine learning models. Just as a Swiss Army knife has various tools that can be used for different purposes – a screwdriver for fixing something, scissors for cutting, or a bottle opener for enjoying a drink – the UAF can adapt to various tasks in ML. Each part of the UAF acts like a specific tool that can be utilized depending on what challenge your model faces, whether it’s prediction, classification, or feature transformation.
Troubleshooting
If you encounter any issues during the process, here are some troubleshooting tips:
- Docker Issues: Make sure Docker is running and that you have allocated enough resources (CPU, memory) to your containers.
- CUDA Compatibility Errors: Double-check that your CUDA installation matches the version required by TensorFlow or PyTorch.
- Package Installation Problems: If you face difficulties with pip installations, ensure that your internet connection is stable during the package downloads and installations.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.