Skip to content

Instantly share code, notes, and snippets.

@agnesmm

agnesmm/a2g1.py Secret

Last active September 17, 2017 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agnesmm/ce342d8e5da79da17a9bc27eb02ed496 to your computer and use it in GitHub Desktop.
Save agnesmm/ce342d8e5da79da17a9bc27eb02ed496 to your computer and use it in GitHub Desktop.
from keras import backend as K
from keras.applications.vgg16 import VGG16
from keras.layers import Flatten, Dense, Input
from keras.models import Model, load_model
from keras.optimizers import Adam, RMSprop, SGD
from keras.preprocessing.image import ImageDataGenerator
path = 'data/dogscats_redux/'
target_size = (224, 224)
batch_size = 64
model_path = path + 'models/'
def get_batches(directory, target_size=target_size, batch_size=batch_size, shuffle=False):
datagen = ImageDataGenerator()
return datagen.flow_from_directory(directory=directory,
target_size=target_size,
batch_size=batch_size,
class_mode='categorical',
shuffle=shuffle)
batches = get_batches(path+'train', shuffle=True)
valid_batches = get_batches(path+'valid', batch_size=batch_size*2, shuffle=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment