This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch.nn.functional as F | |
from pytorch_lightning import seed_everything, LightningModule, Trainer | |
from pytorch_lightning.callbacks import EarlyStopping | |
from torch import nn, optim, rand, sum as tsum, reshape, save | |
from torch.utils.data import DataLoader, Dataset | |
SAMPLE_DIM = 21000 | |
class CustomDataset(Dataset): | |
def __init__(self, samples=42): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
torch.manual_seed(42) | |
x_tensor = torch.from_numpy(x).float() | |
y_tensor = torch.from_numpy(y).float() | |
# Builds dataset with ALL data | |
dataset = TensorDataset(x_tensor, y_tensor) | |
# Splits randomly into train and validation datasets | |
train_dataset, val_dataset = random_split(dataset, [80, 20]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get Apple Health data as Pandas DataFrame | |
# === | |
# pre-reqs: python3, lxml, pandas | |
# to get started: | |
# export and mail yourself your data following steps within the Health app on iPhone | |
# download and unzip contents of exported zip file; find path to export.xml and set path_to_exportxml below | |
import pandas as pd | |
import xml.etree.ElementTree | |
import datetime |