def main(): try: #capture the command line arguments from the interface script. args = get_args() #parse the configuration parameters for the cnn model config = ConfigurationParameters(args) except: print('Missing or invalid arguments !') exit(0) #load the dataset from the library and print the details dataset = LoadDataCifar10(config, dataset) #construct , build, compile and train the cnn model model = CNNCifar10Model(config, dataset) #save the model to the disk #model.save_model() #generate graphs classfication report, confusion matrix report = Report(config, model) report.plot() report.model_classification_report() report.plot_confusion_matrix()
def main(): try: # Capture the command line arguments from the interface script. args = get_args() # Parse the configuration parameters for the ConvNet Model. config = ConfigurationParameters(args) except: print('Missing or invalid arguments !') exit(0) # Load the dataset from the library, process and print its details. dataset = FashionMnistLoader(config) # Test the loaded dataset by displaying the first image in both training and testing dataset. dataset.display_data_element('train_data', 1) dataset.display_data_element('test_data', 1) # Construct, compile, train and evaluate the ConvNet Model. model = FashionMnistModel(config, dataset) # Save the ConvNet model to the disk. # model.save_model() # Generate graphs, classification report, confusion matrix. report = Report(config, model) report.plot() report.model_classification_report() report.plot_confusion_matrix()
def main(): try: args = get_args() #Parse the configuration ConfigurationParameters config = ConfigurationParameters(args) except: print('Missing or invalid arguments !') exit(0) dataset = LoadDataCifar10(config) g_search = GridSearchBase(config,dataset) #create a Scikit learn wrapper g_search.model_wrapper = KerasClassifier(build_fn = g_search.create_model, verbose=0) #define the grid search parameters batch_size = [1,2] epochs = [30,50] g_search.param_grid = dict(batch_size = batch_size, epochs = epochs) g_search.grid = GridSearchCV(estimator=g_search.model_wrapper,\\ param_grid = g_search.param_grid,\\ n_jobs = g_search.n_jobs) g_search.grid_result = g_search.grid.fit(dataset.train_data,\\ dataset.train_label_one_hot) #summarize results print("best :%f using %s" %(g_search.grid_result.best_score_,\\ g_search.grid_result.best_params_)) means = g_search.grid_result.cv_results_['mean_test_score'] stds = g_search.grid_result.cv_results_['std_test_score'] params = g_search.grid_result.cv_results_['params'] for mean,stdev,param in zip(means, stds, params): print("%f (%f) with: %r" %(mean, stdev, param))