Skip to content

Instantly share code, notes, and snippets.

View cosmozhang's full-sized avatar
🏠
Working from home

Cosmo Zhang cosmozhang

🏠
Working from home
View GitHub Profile
@cosmozhang
cosmozhang / parser.py
Created January 16, 2019 15:59 — forked from BarclayII/parser.py
PyTorch neural parser based on DyNet implementation
'''
Original implementation
https://github.com/clab/dynet_tutorial_examples/blob/master/tutorial_parser.ipynb
The code structure and variable names are similar for better reference.
Not for serious business, just for some comparison between PyTorch and DyNet
(and I still prefer PyTorch)
'''
import torch as T
@Tushar-N
Tushar-N / pad_packed_demo.py
Last active December 27, 2022 06:35
How to use pad_packed_sequence in pytorch<1.1.0
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
seqs = ['gigantic_string','tiny_str','medium_str']
# make <pad> idx 0
vocab = ['<pad>'] + sorted(set(''.join(seqs)))
# make model
@paclopes
paclopes / HungarianCUDA.cu
Last active April 2, 2023 14:37
Fast CUDA implementation of the Hungarian algorithm.
// Fast Block Distributed CUDA Implementation of the Hungarian Algorithm
//
// Annex to the paper:
// Paulo A. C. Lopes, Satyendra Singh Yadav, Aleksandar Ilic, Sarat Kumar Patra ,
// "Fast Block Distributed CUDA Implementation of the Hungarian Algorithm",
// Parallel Computing
//
// Hungarian algorithm:
// (This algorithm was modified to result in an efficient GPU implementation, see paper)
//
@brentp
brentp / betareg.py
Last active June 24, 2022 11:46
beta regression in statsmodels
# -*- coding: utf-8 -*-
u"""
Beta regression for modeling rates and proportions.
References
----------
Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression
in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in
Economics and Statistics, 2011.