Skip to content

Instantly share code, notes, and snippets.

# Lifted verbatim from https://pytorch.org/tutorials/beginner/knowledge_distillation_tutorial.html
# Only for illustrating the distillation training loop as a code fragment.
for epoch in range(epochs):
running_loss = 0.0
for inputs, labels in train_loader:
inputs, labels = inputs.to(device), labels.to(device)
optimizer.zero_grad()
@aurotripathy
aurotripathy / softmax-temperature.ipynb
Created February 4, 2024 00:07
softmax temp illustration
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Dataset utils and dataloaders
import glob
import logging
import math
import os
import random
import shutil
import time
from itertools import repeat
#!/usr/bin/env python3
import logging
import os
from furiosa import runtime
from furiosa.runtime import session
import numpy as np
LOGLEVEL = os.environ.get('FURIOSA_LOG_LEVEL', 'INFO').upper()
logging.basicConfig(level=LOGLEVEL)
#!/usr/bin/env python3
"""
Calibration data/images is from the data folder
from https://github.com/derronqi/yolov7-face
"""
import sys
import onnx
import torch
"""
The model is from https://github.com/derronqi/yolov7-face
Here, we download yolov7s-face.pt and convert it.
Output is model.onnx
"""
import torch
from models.experimental import attempt_load
from pudb import set_trace
from utils.torch_utils import select_device
batch_size = 1
@aurotripathy
aurotripathy / nexoptics_tfl_model.py
Created April 4, 2023 08:41
missing depth2space op
import logging
import os
from furiosa import runtime
from furiosa.runtime import session
import numpy as np
LOGLEVEL = os.environ.get('FURIOSA_LOG_LEVEL', 'INFO').upper()
logging.basicConfig(level=LOGLEVEL)
@aurotripathy
aurotripathy / compile_run.py
Created April 3, 2023 15:50
example of a model that does not fit.
#!/usr/bin/env python3
import logging
import os
from furiosa import runtime
from furiosa.runtime import session
import numpy as np
LOGLEVEL = os.environ.get('FURIOSA_LOG_LEVEL', 'INFO').upper()
logging.basicConfig(level=LOGLEVEL)
@aurotripathy
aurotripathy / repl-qa.py
Created March 20, 2023 15:48
simple read-eval-print-loop for a CahtGPT based bot
import openai
import argparse
MODEL = "gpt-3.5-turbo" # the chatGPT model
system_role_dict = {"role": "system", "content": "You are a helpful assistant."}
alternating_user_assistant_role = []
messages = [system_role_dict]
quit_words = ["--quit", "--bye", "--exit"]
def create_context_as_dict(response):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.