Skip to content

Eduardo-RP/Pretrained-AlexNet-TensorFlow-with-Weights

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 

Repository files navigation

AlexNet TensorFlow with Weights h5

Getting Started

Since 2012, AlexNet is one of the most used architectures in Deep Learning for image classification. This model was trained using ImageNet dataset. The pretrained-AlexNet model can be found in PyTorch, however, it doesn´t exist a guide for Tensorflow implementation. Therefore, this repo include a guide for that purpose.

To generate our pretrained-AlexNet for Keras/TensorFlow, we used the weights found here and can be downloaded from here. Nonetheless, to implement this version of pretrained-AlexNet you have to load the whole architecture and assign the weights to each layer. Thus, for a cleaner implementation of the pretrained-AlexNet model we proposed this repo with the pretrained-AlexNet model in .h5 format.

We tested our pretrained-AlexNet using Anaconda (2.3.1) and Spyder (5.2.2 and 5.3.3) with the next dependencies on Windows 10 in a NVIDIA GeForce RTX 3060 GPU and NVIDIA GeForce RTX 2070 Super.

Installation

  1. Install Visual Studio 2015,2017,2019, and 2022.

  2. Install CUDA 11.3.1. This step is crucial because AlexNet arquitecture was designed with the delineation of responsabilities between two GPUs. Nevertheless, by explicit installing CUDA it allows to implement AlexNet using just one GPU. Note: First check if you have preinstalled a CUDA version before, if not just install as above. In the case that you have a CUDA version, you need to change the new ptxas.exe file from your new CUDA version to the older one installed. You can check if you have a CUDA installed in C:/ProgramFiles/NVIDIA GPU Computing Toolkit/CUDA/.

  3. Create a new environment in Anaconda.

        a) Go to "Environments" in Anaconda Navigator.

        b) Go to "Create".

        c) In the appering window assign a name for your new environment, select Python package 3.7.13, and create the new environment.

Env_image

  1. Open Anaconda Prompt Terminal. This step can be performed seeking in Windows searcher "Anaconda Prompt". Or with the following guide in Anaconda Navigator. Note: in this repo our new environment was named "redes2".

        Go to "Environments", under the name of your new environment select "Play" button and "Open Terminal".

AnPrompt-image

Make sure that you are working in the environment just created verifying the name in parenthesis showed in the Terminal. As it is shown next.

Env_terminal

  1. Install TensorFlow 2.10 in the environment just created in Anaconda with Anaconda Prompt.
conda install –c conda-forge cudatoolkit=11.2 cudnn=8.1.0
pip install tensorflow==2.10

Usage

  1. Download our pretrained-AlexNet for Keras/TensorFlow implementation.

  2. Read the h5 file from Spyder with the following.

    import tensorflow as tf
    alexnet_model = tf.keras.models.load_model('/.../alexnet.h5')
  3. Corroborate the loading of our model.

    alexnet_model.summary()

Contact

Armando Reyes - LinkedIn - reyesarmando.reyes@gmail.com

Eduardo Rivas - LinkedIn - eduardo.rivasp@ieee.org

Note: both authors contributed equally in this project. 😃

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published