Skip to content

Instantly share code, notes, and snippets.

View Chris-hughes10's full-sized avatar

Chris Hughes Chris-hughes10

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Chris-hughes10
Chris-hughes10 / install-AzCopy.sh
Created June 9, 2022 09:27 — forked from aessing/install-AzCopy.sh
Install AzCopy on Linux
#!/bin/bash
# =============================================================================
# Install AzCopy on Linux
# https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10
# https://github.com/Azure/azure-storage-azcopy
# -----------------------------------------------------------------------------
# Developer.......: Andre Essing (https://www.andre-essing.de/)
# (https://github.com/aessing)
# (https://twitter.com/aessing)
# (https://www.linkedin.com/in/aessing/)
@Chris-hughes10
Chris-hughes10 / timm.ipynb
Last active April 23, 2024 07:51
timm.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Chris-hughes10
Chris-hughes10 / train.py
Created January 27, 2022 16:58
timm blog - Training script using timm and PyTorch-accelerated
import argparse
from pathlib import Path
import timm
import timm.data
import timm.loss
import timm.optim
import timm.utils
import torch
import torchmetrics
@Chris-hughes10
Chris-hughes10 / parser_image_name.py
Created January 27, 2022 14:53
timm blog - custom parser
from pathlib import Path
from timm.data.parsers.parser import Parser
class ParserImageName(Parser):
def __init__(self, root, class_to_idx=None):
super().__init__()
self.root = Path(root)
@Chris-hughes10
Chris-hughes10 / Recommender blog post.ipynb
Created December 9, 2021 09:19
Comparing matrix factorixation with transformers using pytorch-accelerated blog post.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Chris-hughes10
Chris-hughes10 / recommender_metrics_callback.py
Created December 9, 2021 07:43
Recommender Blog: Torchmetrics recommender callback
from pytorch_accelerated.callbacks import TrainerCallback
import torchmetrics
class RecommenderMetricsCallback(TrainerCallback):
def __init__(self):
self.metrics = torchmetrics.MetricCollection(
{
"mse": torchmetrics.MeanSquaredError(),
"mae": torchmetrics.MeanAbsoluteError(),
}
@Chris-hughes10
Chris-hughes10 / mf_model.py
Created December 9, 2021 07:39
Recommender blog: matrix factorization model
import torch
from torch import nn
class MfDotBias(nn.Module):
def __init__(
self, n_factors, n_users, n_items, ratings_range=None, use_biases=True
):
super().__init__()
self.bias = use_biases
@Chris-hughes10
Chris-hughes10 / train_with_metrics_in_callback.py
Created November 24, 2021 11:28
pytorch_accelerated_blog_metrics_in_callback
# https://github.com/Chris-hughes10/pytorch-accelerated/blob/main/examples/metrics/train_with_metrics_in_callback.py
import os
from torch import nn, optim
from torch.utils.data import random_split
from torchmetrics import MetricCollection, Accuracy, Precision, Recall
from torchvision import transforms
from torchvision.datasets import MNIST
@Chris-hughes10
Chris-hughes10 / classification_metrics_callback.py
Created November 24, 2021 11:22
pytorch_accelerated_blog_metrics_callback_snippet
from torchmetrics import MetricCollection, Accuracy, Precision, Recall
from pytorch_accelerated.callbacks import TrainerCallback
class ClassificationMetricsCallback(TrainerCallback):
def __init__(self, num_classes):
self.metrics = MetricCollection(
{
"accuracy": Accuracy(num_classes=num_classes),