mirror of
https://github.com/webclinic017/drift.git
synced 2026-08-15 03:48:09 +00:00
feature(Models): Implemented a basic Neural Network with Pytorch-Lightning (#101)
* feat: Added base functions for Neural Net. * feat: Added function to handle Neural Nets. * fix: Fixed fit loop * feat: Neural Net trains now, need to test it. * feat: Prediction now works on the neural net. * fix: Put back config and run_pipeline.py * fix: Took out import from run_pipeline. * fix(Models): added get_name(), adjusted pytorch model output size * fix(Tests): fixed tests Co-authored-by: Mark Aron Szulyovszky <mark.szulyovszky@gmail.com>
This commit is contained in:
co-authored by
Mark Aron Szulyovszky
parent
1cd0119589
commit
ee35332f58
@@ -0,0 +1,26 @@
|
||||
import os
|
||||
import pandas as pd
|
||||
|
||||
import torch
|
||||
from torch.utils.data import Dataset
|
||||
from torch.utils.data import DataLoader
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
class TimeSeriesDataset(Dataset):
|
||||
def __init__(self, X: np.ndarray, y: np.ndarray):
|
||||
self.X = X
|
||||
self.y = y
|
||||
|
||||
def __len__(self):
|
||||
return len(self.X)
|
||||
|
||||
def __getitem__(self, idx):
|
||||
return self.X[idx].astype(float), self.y[idx].astype(float)
|
||||
|
||||
def get_dataloader(X: np.ndarray, y: np.ndarray, batch_size: int = 32, shuffle: bool = True):
|
||||
training_data = TimeSeriesDataset(X, y)
|
||||
train_dataloader = DataLoader(training_data, batch_size=batch_size, shuffle=shuffle)
|
||||
|
||||
return train_dataloader
|
||||
Reference in New Issue
Block a user