Test doxygen

This commit is contained in:
Harle, Antoine (Contracteur) 2020-01-24 15:10:08 -05:00
parent f507ff4741
commit 99f15b8946
4 changed files with 54 additions and 25 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
/higher/data
/higher/samples
/higher/doc
/Gradient-Descent-The-Ultimate-Optimizer/data
/FAR-HO/data
/__pycache__

View file

@ -6,12 +6,17 @@ import torch
from torch.utils.data import SubsetRandomSampler
import torchvision
#Train/Validation batch size.
BATCH_SIZE = 300
TEST_SIZE = 300
#Test batch size.
TEST_SIZE = BATCH_SIZE
#TEST_SIZE = 10000 #legerement +Rapide / + Consomation memoire !
#Wether to download data.
download_data=False
#Number of worker to use.
num_workers=2 #4
#Pin GPU memory
pin_memory=False #True :+ GPU memory / + Lent
#ATTENTION : Dataug (Kornia) Expect image in the range of [0, 1]
@ -37,8 +42,10 @@ transform = torchvision.transforms.Compose([
#)
### Classic Dataset ###
#Training data
data_train = torchvision.datasets.CIFAR10("../data", train=True, download=download_data, transform=transform)
#data_val = torchvision.datasets.CIFAR10("../data", train=True, download=download_data, transform=transform)
#Testing data
data_test = torchvision.datasets.CIFAR10("../data", train=False, download=download_data, transform=transform)
train_subset_indices=range(int(len(data_train)/2))

View file

@ -5,7 +5,13 @@ import torch.nn.functional as F
## Basic CNN ##
class LeNet(nn.Module):
"""Basic CNN.
"""
def __init__(self, num_inp, num_out):
"""Init LeNet.
"""
super(LeNet, self).__init__()
self.conv1 = nn.Conv2d(num_inp, 20, 5)
self.pool = nn.MaxPool2d(2, 2)
@ -15,6 +21,9 @@ class LeNet(nn.Module):
self.fc2 = nn.Linear(500, num_out)
def forward(self, x):
"""Main method of LeNet
"""
x = self.pool(F.relu(self.conv1(x)))
x = self.pool2(F.relu(self.conv2(x)))
x = x.view(x.size(0), -1)
@ -23,4 +32,7 @@ class LeNet(nn.Module):
return x
def __str__(self):
""" Get name of model
"""
return "LeNet"

View file

@ -18,15 +18,18 @@ import torch
import kornia
import random
#TF that don't have use for magnitude parameter.
TF_no_mag={'Identity', 'FlipUD', 'FlipLR', 'Random', 'RandBlend'}
#TF which implemetation doesn't allow gradient propagaition.
TF_no_grad={'Solarize', 'Posterize', '=Solarize', '=Posterize'}
#TF for which magnitude should be ignored (Magnitude fixed).
TF_ignore_mag= TF_no_mag | TF_no_grad
TF_no_mag={'Identity', 'FlipUD', 'FlipLR', 'Random', 'RandBlend'} #TF that don't have use for magnitude parameter.
TF_no_grad={'Solarize', 'Posterize', '=Solarize', '=Posterize'} #TF which implemetation doesn't allow gradient propagaition.
TF_ignore_mag= TF_no_mag | TF_no_grad #TF for which magnitude should be ignored (Magnitude fixed).
# What is the max 'level' a transform could be predicted
PARAMETER_MAX = 1
# What is the min 'level' a transform could be predicted
PARAMETER_MIN = 0.1
PARAMETER_MAX = 1 # What is the max 'level' a transform could be predicted
PARAMETER_MIN = 0.1 # What is the min 'level' a transform could be predicted
### Available TF for Dataug ###
# Dictionnary mapping tranformations identifiers to their function.
# Each value of the dict should be a lambda function taking a (batch of data, magnitude of transformations) tuple as input and returns a batch of data.
TF_dict={ #Dataugv5+
@ -416,7 +419,10 @@ def blend(x,y,alpha):
return res
#Not working
def auto_contrast(x): #PAS OPTIMISE POUR DES BATCH #EXTRA LENT
def auto_contrast(x):
"""NOT TESTED - EXTRA SLOW
"""
# Optimisation : Application de LUT efficace / Calcul d'histogramme par batch/channel
print("Warning : Pas encore check !")
(batch_size, channels, h, w) = x.shape
@ -452,7 +458,10 @@ def auto_contrast(x): #PAS OPTIMISE POUR DES BATCH #EXTRA LENT
#print('End',x[0])
return float_image(x)
def equalize(x): #PAS OPTIMISE POUR DES BATCH
def equalize(x):
""" NOT WORKING
"""
raise Exception(self, "not implemented")
# Optimisation : Application de LUT efficace / Calcul d'histogramme par batch/channel
(batch_size, channels, h, w) = x.shape