Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How to do train test split in keras Imagedatagenerator

train_datagen = ImageDataGenerator(rescale=1./255,
    shear_range=0.2,
    zoom_range=0.2,
    horizontal_flip=True,
    validation_split=0.2) # set validation split

train_generator = train_datagen.flow_from_directory(
    train_data_dir,
    target_size=(img_height, img_width),
    batch_size=batch_size,
    class_mode='binary',
    subset='training') # set as training data

validation_generator = train_datagen.flow_from_directory(
    train_data_dir, # same directory as training data
    target_size=(img_height, img_width),
    batch_size=batch_size,
    class_mode='binary',
    subset='validation') # set as validation data

model.fit_generator(
    train_generator,
    steps_per_epoch = train_generator.samples // batch_size,
    validation_data = validation_generator, 
    validation_steps = validation_generator.samples // batch_size,
    epochs = nb_epochs)
Comment

PREVIOUS NEXT
Code Example
Python :: select rows from a list of indices pandas 
Python :: Python pandas first and last element of column 
Python :: python average of list 
Python :: pandas bin columns 
Python :: # find out of the memory of the python object 
Python :: pip install python-telegram-bot 
Python :: python lock using a file 
Python :: pandas drop row from a list of value 
Python :: multiclass ROC AUC curve 
Python :: python efficiently find duplicates in list 
Python :: python comment block 
Python :: get name of variable python 
Python :: how to set background image in python tkinter 
Python :: matplotlib boxplot colors 
Python :: python print odd numberrs 
Python :: django migrate not creating tables 
Python :: pandas index between time 
Python :: how to import from parent directory 
Python :: how to remove all 2 in a list python 
Python :: strip first occurence of substring python 
Python :: hex to rgb python 
Python :: django login view 
Python :: selenium firefox webdriver 
Python :: how to check if a list is nested or not 
Python :: python mixins 
Python :: check remote port is open or not using python 
Python :: convert pdf to csv python 
Python :: how to remove a tuple from a list python 
Python :: sum all values in a matrix python 
Python :: odd or even python 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =