Added generic pytorch implementation for multi layer linear NN.

This commit is contained in:
Daniel Ledda
2020-07-11 12:02:22 +02:00
parent ce4172da5d
commit 88508a0d07
15 changed files with 171 additions and 30 deletions

22
custom_types.py Normal file
View File

@@ -0,0 +1,22 @@
import torch
from typing import Tuple, NamedTuple, List, Callable
import numpy as np
TrainingBatch = Tuple[List[List[float]], List[int]]
class LossFun(NamedTuple):
exec: Callable[[np.array, np.array], float]
deriv: Callable[[np.array, np.array], np.array]
class EvaluationResults(NamedTuple):
total: int
correct: int
accumulated_loss: float
if torch.cuda.is_available():
DEVICE = "cuda:0"
else:
DEVICE = "cpu"