Skip to content

Instantly share code, notes, and snippets.

View koshian2's full-sized avatar

こしあん koshian2

View GitHub Profile
@koshian2
koshian2 / pytorch_fp32.py
Last active May 23, 2019 13:12
PyTorch FP32
import torch
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
from pytorch_models import Layer10CNN, WideResNet
import numpy as np
import datetime
import time
import pickle
import tensorflow as tf
import tensorflow.python.keras as keras
import tensorflow.python.keras.layers as layers
import tensorflow.python.keras.backend as K
from tensorflow.contrib.tpu.python.tpu import keras_support
import datetime
import time
import pickle
import os
import numpy as np
@koshian2
koshian2 / gpu_tpu_1.py
Created May 14, 2019 00:05
GPU vs TPU 1
import tensorflow as tf
import tensorflow.python.keras as keras
import tensorflow.python.keras.layers as layers
from tensorflow.contrib.tpu.python.tpu import keras_support
import datetime
import time
import pickle
import os
def conv_bn_relu(input, ch, reps):
@koshian2
koshian2 / error_analysis_cifar.py
Last active February 25, 2020 12:38
Manual augmentaion in CIFAR-10
import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.models import Model
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.callbacks import Callback, History, LearningRateScheduler
from tensorflow.keras.optimizers import SGD
from tensorflow.contrib.tpu.python.tpu import keras_support
from sklearn.metrics import confusion_matrix
from tensorflow.keras.datasets import cifar10
@koshian2
koshian2 / increase_batchsize.py
Created February 18, 2019 03:49
Don't Decay the Learning Rate, Increase the Batch Size
import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.models import Model
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.callbacks import History, LearningRateScheduler
from tensorflow.keras.optimizers import SGD
from tensorflow.contrib.tpu.python.tpu import keras_support
import tensorflow.keras.backend as K
from keras.datasets import cifar10
@koshian2
koshian2 / case4.py
Created January 28, 2019 12:53
BC-learning case4
import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.models import Model
from tensorflow.keras.callbacks import History, LearningRateScheduler
from tensorflow.contrib.tpu.python.tpu import keras_support
from tensorflow.keras.optimizers import SGD
import tensorflow.keras.backend as K
from keras.regularizers import l2
import numpy as np
@koshian2
koshian2 / case5.py
Created January 28, 2019 12:52
BC-learning case5
import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.models import Model
from tensorflow.keras.callbacks import History, LearningRateScheduler
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.contrib.tpu.python.tpu import keras_support
from tensorflow.keras.optimizers import SGD
import tensorflow.keras.backend as K
from keras.regularizers import l2
@koshian2
koshian2 / arccos_triplet.py
Created January 25, 2019 13:43
Train with 1000 arccos triplet loss
import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.models import Model
from tensorflow.keras.callbacks import Callback, History, LearningRateScheduler
import tensorflow.keras.backend as K
from tensorflow.contrib.tpu.python.tpu import keras_support
from train1000 import cifar10
import numpy as np
from sklearn.metrics.pairwise import cosine_similarity
@koshian2
koshian2 / euclidean_triplet.py
Last active January 25, 2019 13:29
Train with 1000 triplet loss euclidean distance
import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.models import Model
from tensorflow.keras.callbacks import Callback, History, LearningRateScheduler
import tensorflow.keras.backend as K
from tensorflow.contrib.tpu.python.tpu import keras_support
from train1000 import cifar10
import numpy as np
from sklearn.metrics import accuracy_score, euclidean_distances
@koshian2
koshian2 / simple_softmax.py
Created January 25, 2019 05:50
simple_softmax
import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.models import Model
from tensorflow.keras.callbacks import Callback, History
import tensorflow.keras.backend as K
from tensorflow.contrib.tpu.python.tpu import keras_support
from train1000 import cifar10
import numpy as np
import os, json, tarfile