Skip to content

Instantly share code, notes, and snippets.

View satomshr's full-sized avatar

Masahiro SATO satomshr

View GitHub Profile
@satomshr
satomshr / imagedatagenerator_randomized_search.py
Last active February 23, 2021 23:01
Parameters optimization of ImageDataGenerator using randomized search
import tensorflow as tf
from tensorflow.keras import layers, models
from keras.callbacks import ReduceLROnPlateau
from keras.preprocessing.image import ImageDataGenerator
from sklearn.model_selection import train_test_split
import time
import random
# load data
train_data = pd.read_csv("/kaggle/input/digit-recognizer/train.csv")
@satomshr
satomshr / imagedatagenerator_gpyopt.py
Last active February 23, 2021 05:52
Parameters optimization of ImageDataGenerator using GPyOpt
import tensorflow as tf
from tensorflow.keras import layers, models
from keras.callbacks import ReduceLROnPlateau
from keras.preprocessing.image import ImageDataGenerator
from sklearn.model_selection import train_test_split
# Install Gpyopt
!pip install GPyOpt
import GPy, GPyOpt
@satomshr
satomshr / imagedatagenerator.py
Created January 11, 2021 10:15
Parameters of ImageDataGenerator for kaggle / MNIST
from keras.preprocessing.image import ImageDataGenerator
def image_data_generator():
return ImageDataGenerator(rotation_range=30,
width_shift_range=0.20,
height_shift_range=0.20,
shear_range=0.2,
zoom_range=0.2,
fill_mode='nearest')
@satomshr
satomshr / callbacks.py
Last active January 11, 2021 10:16
Callbacks for kaggle / MNIST
from keras.callbacks import ModelCheckpoint, ReduceLROnPlateau
model_checkpoint_callback = ModelCheckpoint(filepath=os.path.join("./weights/", "model-{epoch:02d}-{val_loss:.4f}.hdf5"),
monitor='val_loss',
mode='min',
save_best_only=True)
reduce_lr_callback = ReduceLROnPlateau(monitor='val_loss',
factor=0.47,
patience=5,
@satomshr
satomshr / cnn_model.py
Created January 11, 2021 10:12
CNN model for kaggle / MNIST
import tensorflow as tf
from tensorflow.keras import layers, models
model = models.Sequential()
model.add(layers.Conv2D(128, (7, 7), activation='relu', padding='same', input_shape=(28, 28, 1)))
model.add(layers.Dropout(0.4))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(256, (3, 3), activation='relu'))
model.add(layers.Dropout(0.4))
@satomshr
satomshr / hello_world.py
Created January 9, 2021 06:14
test of gist (public)
print("Hello, World!")