Skip to content

Instantly share code, notes, and snippets.

@amineHY
amineHY / Deep_CNN.py
Created April 12, 2019 22:39
This code is the implementation of a CNN in PyTorch
# Implementation of CNN/ConvNet Model using PyTorch (depicted in the picture above)
class CNN(torch.nn.Module):
def __init__(self):
super(CNN, self).__init__()
# L1 ImgIn shape=(?, 28, 28, 1)
# Conv -> (?, 28, 28, 32)
# Pool -> (?, 14, 14, 32)
self.layer1 = torch.nn.Sequential(
@amineHY
amineHY / Importing_MNIST_dataset.py
Last active April 13, 2019 10:26
This code import the MNIST dataset in Python
import torch
import torchvision.datasets as dsets
batch_size = 32
# MNIST dataset
mnist_train = dsets.MNIST(root='MNIST_data/',
train=True,
transform=transforms.ToTensor(),
@amineHY
amineHY / training_CNN.py
Last active April 19, 2019 15:30
This code implement the training of a CNN in python using PyTorch
print('Training the Deep Learning network ...')
learning_rate = 0.001
criterion = torch.nn.CrossEntropyLoss() # Softmax is internally computed.
optimizer = torch.optim.Adam(params=model.parameters(), lr=learning_rate)
train_cost = []
train_accu = []
batch_size = 32
training_epochs = 15
@amineHY
amineHY / FaceNet_triplet_loss.py
Last active April 24, 2019 12:07
This function implement the computation of the triplet loss function for the face recognition application
def triplet_loss_function(im_anchor, im_positive, im_negative, alpha = 0.2):
"""
Implementation of the triplet loss function
Source: https://arxiv.org/pdf/1503.03832.pdf
Arguments:
y_pred -- python list containing three objects:
anchor -- the encodings for the anchor images, of shape (None, 128)
positive -- the encodings for the positive images, of shape (None, 128)
xhost +
docker run -it --rm -v $(pwd):/workspace \
--runtime=nvidia -w /workspace \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=$DISPLAY \
-p 8888:8888 -p 6006:6006
aminehy/ai-lab:latest
@amineHY
amineHY / keybase.md
Created December 12, 2019 11:17
keybase.md

Keybase proof

I hereby claim:

  • I am aminehy on github.
  • I am amine_hy (https://keybase.io/amine_hy) on keybase.
  • I have a public key ASCuvs4CY-NYKpzwhW2V2aA9nBkxefzj8bRld7Vvx_TRGAo

To claim this, I am signing this object:

@amineHY
amineHY / environment.yaml
Last active November 28, 2020 13:47
YAML file to setup conda envirenment
name: app
channels:
- conda-forge
- anaconda
dependencies:
- flask
- gunicorn
- pip:
@amineHY
amineHY / Dockerfile
Created November 27, 2020 13:16
This is a Dockerfile for a python project using conda environment
FROM continuumio/miniconda3
LABEL Author, Amine HadjYoucef
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY . $APP_HOME
#---------------- Prepare the envirennment
RUN conda update --name base conda &&\
conda env create --file environment.yaml
@amineHY
amineHY / main.py
Last active November 28, 2020 20:03
Hello World python file for testing
import numpy as np
print('Hello World !')
print('Numpy version is ', np.__version__)
@amineHY
amineHY / project structure
Created November 27, 2020 13:40
Simple python project structure
.
├── Dockerfile
├── environment.yaml
├── main.py
└── requirements.py