Skip to content

Final project for the course: Python for (open) Neuroscience, taught by Luigi Petrucco at CIMeC's PhD school (University of Trento).

Notifications You must be signed in to change notification settings

matteo-d-m/python-course-cimec-2023

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository contains the final project for the course:

taught by Luigi Petrucco at the Doctoral school in Cognitive and Brain Sciences, Center for Mind/Brain Sciences (CIMeC), University of Trento.


The project consists of a simple convolutional neural network (CNN) for image recognition. It includes four files:

  • matteos_module.py: a custom Python module that contains classes and functions to define, train, validate, test, and inspect the CNN
  • master_script.py: instantiates and calls matteos_module.py's classes and functions in the right order
  • config.py: dictionaries that contain important (hyper)parameters to control the structure and behaviour of the CNN
  • visual_cnn_notebook.ipynb: a notebook version of the project that collects all the above in a single file

Dependencies:

Language/Package Version tested on
Python 3.9.16
NumPy 1.23.5
Matplotlib 3.7.1
PyTorch 2.0.1
torchvision 0.15.2

The CNN is trained, validated and tested on the MNIST dataset of handwritten digits: a standard (actually, overused) benchmark for machine learning models. However, it works on virtually any other vision dataset with little-to-no modifications.

Training and validating CNNs can be computationally intensive. For this reason, PyTorch is geared towards parallel computing on CUDA-enabled GPUs. If you have one on your machine, the model will run there. If you don't, it will run on your CPU.

Training on CPU might take too long. To avoid this, you can run visual_cnn_notebook.ipynb on Google Colab. This will provide the same results as running the three .py files locally, as these are just a better organized, modular version of the .ipynb. However, training will be significantly faster because it will run on Google's CUDA-enabled GPUs. This project was developed with and tested on version 11.8 of the CUDA Toolkit.

You can check if your GPU is CUDA-enabled here. TL;DR: it must be NVIDIA.


Conceptual background on CNNs and deep learning: