Skip to content

Instantly share code, notes, and snippets.

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):
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])
@thomaswilley
thomaswilley / applehealth.py
Last active May 29, 2024 14:15
Get Apple Health data as Pandas DataFrame
# 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