Skip to content

Instantly share code, notes, and snippets.

View koshian2's full-sized avatar

こしあん koshian2

View GitHub Profile
@koshian2
koshian2 / models.py
Created August 19, 2019 08:34
ACGAN(2) AnimeFace, full, original
import torch
from torch import nn
import torch.nn.functional as F
class Generator(nn.Module):
def __init__(self, n_classes):
super().__init__()
self.linear = nn.Sequential(
nn.Linear(100 + n_classes, 768),
nn.ReLU(True)
@koshian2
koshian2 / models.py
Created August 19, 2019 08:25
ACGAN(1) CIFAR-10
import torch
from torch import nn
class Generator(nn.Module):
def __init__(self):
super().__init__()
self.linear = nn.Sequential(
nn.Linear(110, 384),
nn.ReLU(True)
)
@koshian2
koshian2 / dcgan.py
Created July 31, 2019 16:54
max(log D) DCGAN, CIFAR-10
import torch
from torch import nn
import torch.nn.functional as F
import torchvision
from torchvision import transforms
from tqdm import tqdm
import statistics
import os
import pickle
import glob
@koshian2
koshian2 / dataloader.py
Created July 28, 2019 15:06
Coarse to fine model
import torch
import torchvision
from torchvision import transforms
from PIL import Image, ImageFilter
import numpy as np
from tqdm import tqdm
import glob
import os
def preprocess(n_validation=2048):
@koshian2
koshian2 / rgb_rgb.py
Created June 27, 2019 09:11
Pix2pix STL Colorize
import torch
from torch import nn
import torchvision
import torchvision.transforms as transforms
import numpy as np
from tqdm import tqdm
import os
import pickle
import statistics
@koshian2
koshian2 / cifar.py
Created June 23, 2019 05:52
DCGAN in PyTorch
import torch
from torch import nn
import torchvision
import torchvision.transforms as transforms
import numpy as np
from tqdm import tqdm
import os
import pickle
import statistics
@koshian2
koshian2 / no_stem.txt
Created June 16, 2019 18:40
Pelee Net
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_1 (InputLayer) (None, 32, 32, 3) 0
__________________________________________________________________________________________________
conv2d_2 (Conv2D) (None, 32, 32, 16) 64 input_1[0][0]
__________________________________________________________________________________________________
batch_normalization_v1_2 (Batch (None, 32, 32, 16) 64 conv2d_2[0][0]
__________________________________________________________________________________________________
activation_2 (Activation) (None, 32, 32, 16) 0 batch_normalization_v1_2[0][0]
@koshian2
koshian2 / cifar10.py
Last active December 13, 2019 12:27
Peele Net CIFAR-10
from pelee_net import PeleeNet
import tensorflow as tf
import tensorflow.keras as keras
import numpy as np
from PIL import Image
import pickle
import os
from tensorflow.contrib.tpu.python.tpu import keras_support
def generator(X, y, batch_size, use_augmentation, shuffle, scale):
@koshian2
koshian2 / fp16util.py
Created June 10, 2019 07:28
PyTorch Mixed Precision/FP16
import torch
import torch.nn as nn
from torch.autograd import Variable
from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors
# https://github.com/NVIDIA/apex/blob/master/apex/fp16_utils/fp16util.py
class tofp16(nn.Module):
"""
Utility module that implements::
import torch
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
from pytorch_models import Layer10CNN, WideResNet
from apex import amp
import numpy as np
import datetime
import time
import pickle