lb = LabelBinarizer() trainY = lb.fit_transform(trainY) testY = lb.transform(testY) # construct the image generator for data augmentation aug = ImageDataGenerator(rotation_range=30, width_shift_range=0.1, height_shift_range=0.1, shear_range=0.2, zoom_range=0.2, horizontal_flip=True, fill_mode="nearest") # initialize our VGG-like Convolutional Neural Network model = SmallVGGNet.build(width=64, height=64, depth=3, classes=len(lb.classes_)) # initialize our initial learning rate, # of epochs to train for, # and batch size INIT_LR = 0.01 EPOCHS = 20 BS = 8 # initialize the model and optimizer (you'll want to use # binary_crossentropy for 2-class classification) print("[INFO] training network...") opt = SGD(lr=INIT_LR, decay=INIT_LR / EPOCHS) model.compile(loss="categorical_crossentropy", optimizer=opt, metrics=["accuracy"])
# vector) lb = LabelBinarizer() trainY = to_categorical(trainY) testY = to_categorical(testY) # construct the image generator for data augmentation aug = ImageDataGenerator(rotation_range=30, width_shift_range=0.1, height_shift_range=0.1, shear_range=0.2, zoom_range=0.2, horizontal_flip=True, fill_mode="nearest") # initialize our VGG-like Convolutional Neural Network model = SmallVGGNet.build(width=128, height=128, depth=3, classes=2) # initialize our initial learning rate, # of epochs to train for, # and batch size INIT_LR = 0.01 EPOCHS = 1 BS = 32 # initialize the model and optimizer (you'll want to use # binary_crossentropy for 2-class classification) print("[INFO] training network...") opt = SGD(lr=INIT_LR, decay=INIT_LR / EPOCHS) model.compile(loss="categorical_crossentropy", optimizer=opt, metrics=["accuracy"])