def run_train(params: dict) -> Tuple[threading.Thread, threading.Thread]: """Train a network on a data generator. params -> dictionary. Required fields: * model_name * generator_name * dataset_dir * tile_size * clf_name * checkpoints_dir * summaries_dir Returns prefetch thread & model.fit thread""" assert 'model_name' in params assert 'generator_name' in params Model = ModelFactory.get_model(params['model_name']) Generator = GeneratorFactory.get_generator(params['generator_name']) model = Model(**params) feed = Generator(**params) pf = PreFetch(feed) t1 = threading.Thread(target=pf.fetch) t2 = threading.Thread(target=model.fit, args=(pf,)) t1.start() t2.start() return t1,t2
from callback import MultipleClassAUROC, MultiGPUModelCheckpoint from model import ModelFactory import json output_dir = "C:\\Users\\yanqing.yqh\\code\\wly-chexnet-keras\\modeltrain\\output" train_dir = ( "C:\\Users\\yanqing.yqh\\code\\wly-chexnet-keras\\cats_and_dogs_small\\train" ) validation_dir = ( "C:\\Users\\yanqing.yqh\\code\\wly-chexnet-keras\\cats_and_dogs_small\\validation" ) output_weights_path = os.path.join(output_dir, "weight.h5") class_names = ["dog", "cat"] model_factory = ModelFactory() model = model_factory.get_model(class_names) print(model.summary()) print(len(model.layers)) train_datagen = ImageDataGenerator( samplewise_center=True, samplewise_std_normalization=True, horizontal_flip=True, vertical_flip=False, height_shift_range=0.05, width_shift_range=0.1, rotation_range=5, shear_range=0.1, fill_mode="reflect", zoom_range=0.15, rescale=1.0 / 255,