Skip to content

Instantly share code, notes, and snippets.

@TadaoYamaoka
TadaoYamaoka / qat_fx.py
Created May 27, 2023 03:23
Quantization Aware Training with FX Graph Mode
import os
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision
from torchvision import transforms
from torch.ao.quantization import get_default_qat_qconfig_mapping
from torch.ao.quantization.quantize_fx import prepare_qat_fx, convert_fx
@EdisonLeeeee
EdisonLeeeee / numpy_topk.py
Created October 31, 2021 06:52
Numpy implementation of torch.topk
import numpy as np
from collections import namedtuple
topk_namedtuple = namedtuple('topk_namedtuple', ['values', 'indices'])
def topk(array: np.ndarray, k: int, largest: bool = True) -> topk_namedtuple:
"""Returns the k largest/smallest elements and corresponding indices
from an array-like input.
@interactivetech
interactivetech / pycocotools_tutorial.ipynb
Created January 17, 2021 22:10
Detailed Walkthrough of pycocotools and Python COCO API
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.