Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄
Hello Underworld. Hello 人工稚能.

Lei Mao leimao

🦄
Hello Underworld. Hello 人工稚能.
View GitHub Profile
@leimao
leimao / mm.cu
Last active Mar 27, 2022
Matrix Multiplication and Batched Matrix Multiplication Implementations Using C++ and CUDA.
View mm.cu
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <random>
#include <stdexcept>
#include <vector>
#define BLOCK_DIM 32
@leimao
leimao / jpeg2pdf.sh
Last active Feb 26, 2022
JPEG to PDF Conversion
View jpeg2pdf.sh
# MIT License
# Copyright (c) 2021 Lei Mao <https://leimao.github.io/>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@leimao
leimao / extract_ILSVRC.sh
Last active Jul 8, 2021 — forked from BIGBALLON/extract_ILSVRC.sh
script for ImageNet data extract.
View extract_ILSVRC.sh
#!/bin/bash
#
# script to extract ImageNet dataset
# ILSVRC2012_img_train.tar (about 138 GB)
# ILSVRC2012_img_val.tar (about 6.3 GB)
# make sure ILSVRC2012_img_train.tar & ILSVRC2012_img_val.tar in your current directory
#
# https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md
#
# train/
View valprep.sh
This file has been truncated, but you can view the full file.
mkdir -p n01440764
mkdir -p n01443537
mkdir -p n01484850
mkdir -p n01491361
mkdir -p n01494475
mkdir -p n01496331
mkdir -p n01498041
mkdir -p n01514668
mkdir -p n01514859
View valprep.sh
mkdir -p n01440764
mkdir -p n01443537
mkdir -p n01484850
mkdir -p n01491361
mkdir -p n01494475
mkdir -p n01496331
mkdir -p n01498041
mkdir -p n01514668
mkdir -p n01514859
mkdir -p n01518878
View pytorch_mnist_2.py
import argparse
import os
from filelock import FileLock
import torch.multiprocessing as mp
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
import torch.utils.data.distributed
View resnet_ddp.py
import torch
from torch.utils.data.distributed import DistributedSampler
from torch.utils.data import DataLoader
import torch.nn as nn
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import argparse
@leimao
leimao / graph.py
Last active Jun 20, 2021
Graph Traversal
View graph.py
from typing import Iterable, List, Union, Set
class Graph:
def __init__(self) -> None:
# Adjacency set representation.
# key: node name, value: adjacency node name set.
self.edges = dict()
@leimao
leimao / resnet_ddp.py
Created Jun 20, 2021
PyTorch Distributed Data-Parallel Training for ResNet
View resnet_ddp.py
import torch
from torch.utils.data.distributed import DistributedSampler
from torch.utils.data import DataLoader
import torch.nn as nn
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import argparse
@leimao
leimao / coco.sh
Created May 5, 2021 — forked from mkocabas/coco.sh
Download COCO dataset. Run under 'datasets' directory.
View coco.sh
mkdir coco
cd coco
mkdir images
cd images
wget http://images.cocodataset.org/zips/train2017.zip
wget http://images.cocodataset.org/zips/val2017.zip
wget http://images.cocodataset.org/zips/test2017.zip
wget http://images.cocodataset.org/zips/unlabeled2017.zip