def test_part2_relu_cel_k3(self): start = timer.time() timestamp_pretty = time.strftime("%m/%d/%Y %H:%M:%S") timestamp = time.strftime("%Y%m%d-%H%M%S") print( "####################################################################################################" ) print(f"TestCifar10Model.test_part2_relu_cel_k3: {timestamp_pretty}") print( "####################################################################################################" ) tiny = True epochs = 2 num_workers = 0 activation = nn.ReLU() fc1_channels = 64 kernel_size = 3 batch_size = 4 batch_scalar = 1 loss_function = nn.CrossEntropyLoss() learn_rate = 0.001 momentum = 0 # Train the model model = cm.Cifar10LeNet5(activation=activation, fc1_channels=fc1_channels, kernel_size=kernel_size, batch_size=batch_size, batch_scalar=batch_scalar, tiny=tiny, num_workers=num_workers).to(cm.device) model.fit(loss_function=loss_function, learn_rate=learn_rate, momentum=momentum, epochs=epochs) self.display_visuals(model=model, show_plot=True, save_to_file=True, filename_prefix="part2_relu_cel_k3", folder=f"p2_{timestamp}") elapsed = (time.time() - start) print(f"Time taken: {str(timedelta(seconds=elapsed))} Elapsed\n\n")
def test_part1_all(self): start = timer.time() timestamp_pretty = time.strftime("%m/%d/%Y %H:%M:%S") timestamp = time.strftime("%Y%m%d-%H%M%S") print() print( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ) print(f"~~~~ TestCifar10Model.test_part2_all: {timestamp_pretty}") print( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ) print("\n\n") tiny = True epochs = 1 num_workers = 0 kernel_size = 5 fc1_channels = 16 batch_size = 4 batch_scalar = 1 momentum = 0 # Full Testing params = { 'activation': [nn.Sigmoid(), nn.Tanh()], 'loss_function': [nn.CrossEntropyLoss(), nn.MSELoss()], 'learn_rate': [0.1, 0.01, 0.001], } i = 0 for learn_rate in params['learn_rate']: for activation in params['activation']: for loss_function in params['loss_function']: i += 1 start_iteration = timer.time() start_train = datetime.datetime.now() start_train_str = start_train.strftime("%m/%d/%Y %H:%M:%S") print() print( "####################################################################################################" ) print(f"CASE: {i:02d} Training Started: {start_train_str}") print( "####################################################################################################" ) # Train the model model = cm.Cifar10LeNet5(activation=activation, fc1_channels=fc1_channels, kernel_size=kernel_size, batch_size=batch_size, batch_scalar=batch_scalar, tiny=tiny, num_workers=num_workers).to( cm.device) model.fit(loss_function=loss_function, learn_rate=learn_rate, momentum=momentum, epochs=epochs) self.display_visuals(model=model, show_plot=False, save_to_file=True, filename_prefix="p1_all", folder=f"p1_all_{timestamp}") elapsed = (time.time() - start) print(f"Total Elapsed Time: {str(timedelta(seconds=elapsed))}\n\n")