def main(args): if __name__ == '__main__': args = parse_arguments(sys.argv[1:]) main(args)
def main(args): """The main entry point of the application """ # Parse arguments and check if they exist parsed_arguments = config.parse_arguments(args) if not config.validate_input(parsed_arguments): print('Invalid command line arguments') sys.exit(0) config.setup_logging( default_level=int(parsed_arguments['level']) ) logger.debug('Parsing env variables') env.read_envfile(parsed_arguments['env']) logger.info('Initializing TestRun object') test_run = TestRun() logger.info('Parsing XML file - %s', parsed_arguments['xml']) test_run.update_from_xml(parsed_arguments['xml']) logger.info('Parsing log file - %s', parsed_arguments['log']) test_run.update_from_ica(parsed_arguments['log']) if parsed_arguments['kvp']: logger.info('Getting KVP values from VM') test_run.update_from_vm([ 'OSBuildNumber', 'OSName', 'OSMajorVersion' ], stop_vm=True) # Parse values to be inserted logger.info('Parsing test run for database insertion') insert_values = test_run.parse_for_db_insertion() # Connect to db and insert values in the table logger.info('Initializing database connection') db_connection, db_cursor = sql_utils.init_connection() logger.info('Executing insertion commands') for table_line in insert_values: sql_utils.insert_values(db_cursor, table_line) logger.info('Committing changes to the database') db_connection.commit()
def main(): args = parse_arguments() tga = TGAParser(args.inputfile) if args.encode: bitmap = tga.get_bitmap() low, low_encoded, high, high_quantified = encode(bitmap, args.k) tga.new_tga(low, "low.tga") tga.new_tga_from_bytes(low_encoded, "low_encoded") tga.new_tga(high, "high.tga") tga.new_tga(high_quantified, "high_quantified.tga") if not args.silent: print("\033[4m", "LOW PASS FILTER", "\033[0m") print_stats(bitmap, low) print("\n\033[4m" "HIGH PASS FILTER, QUANTIFIED", "\033[0m") print_stats(bitmap, high_quantified) else: tga.new_tga(decode(tga.bitmap, tga.width, tga.height), "low_decoded.tga")
val_metric) iteration_change_loss += 1 print('-' * 30) train_acc, val_acc = train_metric['accuracy'], val_metric['accuracy'] file_name = ('train_acc_{}_val_acc_{}_epoch_{}.pth'.format( train_acc, val_acc, epoch)) torch.save(cov_net, os.path.join(model_dir, file_name)) if val_acc > best_val_accu: best_val_accu = val_acc if bool(args.save_model): torch.save(cov_net, os.path.join(model_dir, 'best.pth')) if val_loss < best_val_loss: best_val_loss = val_loss iteration_change_loss = 0 if iteration_change_loss == args.patience: print( ('Early stopping after {0} iterations without the decrease ' + 'of the val loss').format(iteration_change_loss)) break t_end_training = time.time() print('training took {}s'.format(t_end_training - t_start_training)) if __name__ == "__main__": args = config.parse_arguments() main(args)
print("Bot items: ", countsToString(bot_counts)) print("Player items: ", countsToString(player_counts)) print("Bot score = ", np.sum(np.multiply(bot_counts, bot_values))) print("Opponent score = ", np.sum(np.multiply(player_counts, opponent_values))) sentinel = input("Type 'quit' to exit, anything else to run another example: ") if (sentinel == 'quit'): break if __name__ == '__main__': args = parse_arguments() with open(args.train_data_json, "r") as fp: trainExamples = json.load(fp) with open(args.train_vocab_json, "r") as fp: vocab = json.load(fp) #testFeatureExtraction() #simpleTest("testing/parseCountsTests.txt") #testResponses("testing/inputs.txt") #completeConversation(trainExamples)
train_loader = torch.utils.data.DataLoader(train_datasets, batch_size=args.batch_size, num_workers=args.workers, pin_memory=True, shuffle=True) test_loader = torch.utils.data.DataLoader(test_datasets, batch_size=args.batch_size, num_workers=args.workers, pin_memory=True, shuffle=True) print('[*] build network...') if args.use_acm is False: net = resnet50(num_classes=100) else: net = acm_resnet50(num_classes=100) if num_gpus > 1 and device == 'cuda': net = nn.DataParallel(net) net = net.to(device) print('[*] start training') writer = SummaryWriter(log_dir) train(args, train_loader, test_loader, net, device, writer, log_dir, checkpoint_dir) if __name__ == '__main__': args = parse_arguments(sys.argv[1:]) main(args)
#!/usr/bin/python # -*- coding: utf-8 -*- import config import eventloop import protocols import transport config.parse_arguments() config.load_from_file() config.store_to_file() loop = eventloop.Eventloop() protocol = protocols.get_default() raw_transport = transport.RawTransport(protocol, loop) loop.run()
env = None device = torch.device("cuda" if torch.cuda.is_available() else "cpu") config = Config() logging.basicConfig(level=20) def main(): ''' run the experiment ''' global env logging.info("Started...") env = utils.make_env(config) n_actions = env.action_space.n qnet = Qnet(n_actions, embedding_size=config.embedding_size).to(device) target_net = Qnet(n_actions, embedding_size=config.embedding_size).to(device) target_net.load_state_dict(qnet.state_dict()) target_net.eval() replay_buffer = ReplayBuffer(config.replay_buffer_size, config.embedding_size, config.path_length) optimizer = torch.optim.Adam(qnet.parameters(), lr=config.lr) value_buffer = ValueBuffer(config.value_buffer_size) train(env, qnet, target_net, optimizer, replay_buffer, value_buffer, config, device) if __name__ == "__main__": parse_arguments(config) main()