Skip to content

Instantly share code, notes, and snippets.

View duoan's full-sized avatar
🎯
Focusing

Victor An duoan

🎯
Focusing
View GitHub Profile
@duoan
duoan / stateful_distibuted_sampler.py
Created January 7, 2026 08:37
A stateful distributed sampler / dataloader
import random
class DistributedSampler:
def __init__(self, dataset_size, world_size, rank,
shuffle=True, seed=0):
self.dataset_size = dataset_size
self.world_size = world_size
self.rank = rank
@duoan
duoan / distributed_sampler.py
Created December 20, 2025 07:49
Python version distributed sampler
"""
A distributed sampler
"""
import math
import random
class DistributedSampler:
def __init__(
@duoan
duoan / resumable_dataloader.py
Created December 20, 2025 07:16
Simply Resumable Dataloader
# %%
# -*- coding: utf-8 -*-
"""
distributed dataloader
"""
import heapq
import time
import random
@duoan
duoan / attention.py
Created February 13, 2025 07:56
MultiHeadAttention
def MultiHeadAttention(nn.Module):
def __init__(self, n_heads: int, head_size: int):
"""Init attention module
Args:
n_heads (int): Number of query, key and value heads.
head_size (int): Dimension size of each attention head.
"""
super(MultiHeadAttention, self).__init__()
self.n_heads = n_heads

安装配置

1. 安装 nvm

nvm 是 Node.js 的版本管理器,可以让你方便地管理 Node.js 版本。

$ cd ~ && curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
Or
$ cd ~ && wget -qO- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
@duoan
duoan / docker-cleanup-resources.md
Created August 19, 2018 07:38 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@duoan
duoan / install_gui_application_darwin.sh
Created July 21, 2018 08:16 — forked from lambdalisue/install_gui_application_darwin.sh
Install Mac OS X Gui Application via Homebrew Cask
#!/usr/bin/env bash
#==============================================================================
# Install Mac OS X GUI Application via brew cask
#==============================================================================
brew cask install google-chrome
brew cask install thunderbird
brew cask install dropbox
brew cask install copy
brew cask install slack
brew cask install the-unarchiver
@duoan
duoan / entity-embedding-rossmann.ipynb
Last active April 8, 2018 14:22
entity-embedding-rossmann sample
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@duoan
duoan / FM&FFM.ipynb
Last active April 8, 2018 14:22
FM & FFM examples
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@duoan
duoan / avazu-ctr-prediction.ipynb
Last active April 8, 2018 14:23
avazu-ctr-rediction summary
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.