This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# you can change the following hyper-parameter | |
penalty_factor = 0.5 # L2 regular term coefficients | |
learning_rate = 0.0005 | |
max_epoch = 200 | |
test_size = 0.25 | |
# ------------------------------------------------------------------ | |
# download the dataset | |
import requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import copy | |
from torch.utils.data import Dataset | |
from torchlearning.mio import MIO, Split | |
class MioDataset(Dataset): | |
def __init__(self, root, sampler, transform=None, target_transform=None): | |
self.root = root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sh -c "$(wget https://gist.githubusercontent.com/chenyaofo/1ba93970fcfd0a05d46e84b30de2268c/raw/08572926d1ae81b45a2b6fa3df50a0d794f2c802/myenv.sh -O -)" | |
sh -c "$(wget https://gist.githubusercontent.com/chenyaofo/1ba93970fcfd0a05d46e84b30de2268c/raw/08572926d1ae81b45a2b6fa3df50a0d794f2c802/myenv_pip.sh -O -)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
import torch | |
import torch.nn | |
import mxnet | |
def test_forward_template(module_name, data, pt_module, mx_module, is_train=True): | |
print(f"Start to test forward process {module_name}, mode = {'train' if is_train else 'validating'}") | |
if not is_train: | |
pt_module.eval() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import typing | |
import functools | |
import torch.nn as nn | |
def intermediate_output_hook(module, input, output, intermediate_output_store: list): | |
intermediate_output_store.append(output) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import flame | |
import torch.distributed as dist | |
def init(backend="nccl", init_method="env://"): | |
if "RANK" in os.environ and "WORLD_SIZE" in os.environ: | |
if dist.is_available(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import flame | |
import torch.distributed as dist | |
def init(backend="nccl", init_method="env://"): | |
if "RANK" in os.environ and "WORLD_SIZE" in os.environ: | |
if dist.is_available(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM nvidia/cuda:10.2-runtime-ubuntu18.04 | |
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 | |
ENV PATH /opt/conda/bin:$PATH | |
RUN APT_INSTALL="apt-get install -y --no-install-recommends" && \ | |
GIT_CLONE="git clone --depth 10" && \ | |
echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse' > /etc/apt/sources.list && \ | |
echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse' >> /etc/apt/sources.list && \ | |
echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse' >> /etc/apt/sources.list && \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# syntax = docker/dockerfile:1.3 | |
FROM nvidia/cuda:11.6.1-runtime-ubuntu20.04 | |
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 \ | |
PATH=/opt/conda/bin:$PATH \ | |
TZ=Asia/Shanghai \ | |
PYTHON_VERSION=3.9 | |
RUN --mount=type=cache,target=/var/cache/apt,id=apt_cache0,sharing=locked --mount=type=cache,target=/var/lib/apt,id=apt_cache1,sharing=locked \ | |
APT_INSTALL="apt-get install -y --no-install-recommends --no-install-suggests" && \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# syntax = docker/dockerfile:1.3 | |
FROM python:3.9-slim as builder | |
WORKDIR /app | |
ENV PYTHONDONTWRITEBYTECODE 1 | |
ENV PYTHONUNBUFFERED 1 | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends build-essential |
OlderNewer