Skip to content

Instantly share code, notes, and snippets.

@chamecall
chamecall / numpy_topk.py
Created August 13, 2024 11:21 — forked from EdisonLeeeee/numpy_topk.py
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.
@chamecall
chamecall / qat_fx.py
Created October 11, 2023 20:12 — forked from TadaoYamaoka/qat_fx.py
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
@chamecall
chamecall / pycocotools_tutorial.ipynb
Created January 25, 2023 08:14 — forked from interactivetech/pycocotools_tutorial.ipynb
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.