Skip to content

Instantly share code, notes, and snippets.

View awni's full-sized avatar

Awni Hannun awni

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@awni
awni / run.py
Created March 29, 2024 02:52
Benchmark Mistral Graph Construction
import time
import mlx.core as mx
import mlx.nn as nn
from dataclasses import dataclass
from typing import Dict, Optional, Tuple, Union
@dataclass
class ModelArgs:
@awni
awni / interspeech_2021_tutorial.ipynb
Created August 28, 2021 15:31
interspeech_2021_tutorial.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@awni
awni / fleiss_kappa.py
Last active May 31, 2018 13:50
A numpy implementation of Fleiss' Kappa
import numpy as np
def fleiss_kappa(ratings):
"""
Args:
ratings: An N x R numpy array. N is the number of
samples and R is the number of reviewers. Each
entry (n, r) is the category assigned to example
n by reviewer r.
Returns:
@awni
awni / ctc_decoder.py
Last active June 1, 2024 14:21
Example CTC Decoder in Python
"""
Author: Awni Hannun
This is an example CTC decoder written in Python. The code is
intended to be a simple example and is not designed to be
especially efficient.
The algorithm is a prefix beam search for a model trained
with the CTC loss function.
@awni
awni / test_perf.py
Created August 6, 2017 18:08
Test PyTorch Attentional performance
import time
import torch
import torch.nn as nn
from torch.autograd import Variable
def attend_bmm(eh, dhx):
dhx = dhx.unsqueeze(1)
pax = torch.bmm(eh, dhx.transpose(1,2)).squeeze(dim=2)
ax = nn.functional.softmax(pax)
@awni
awni / sum_bug.py
Created July 16, 2017 19:26
Variable ByteTensor Sum Bug
import torch
import torch.autograd as autograd
import numpy as np
np.random.seed(11)
for size in range(1, 2000, 1):
a = np.random.randint(0, 2, size).astype(np.uint8)
av = autograd.Variable(torch.ByteTensor(a))