def start_fold(sim_data_node, data_dict, flags, hyper_params, prot_desc_dict, tasks, trainer, transformers_dict, view, prot_profile, k=None): data = trainer.data_provider(k, flags, data_dict) model, optimizer, data_loaders, metrics, frozen_models = trainer.initialize( hparams=hyper_params, train_dataset=data["train"], val_dataset=data["val"], test_dataset=data["test"], protein_profile=prot_profile) if flags["eval"]: trainer.evaluate_model(model, flags["model_dir"], flags["eval_model_name"], data_loaders, metrics, transformers_dict, prot_desc_dict, tasks, view_lbl=view, sim_data_node=sim_data_node) elif flags["explain"]: trainer.explain_model(model, flags["model_dir"], flags["eval_model_name"], data_loaders, transformers_dict, prot_desc_dict, view, sim_data_node) else: # Train the model results = trainer.train(model, optimizer, data_loaders, metrics, frozen_models, transformers_dict, prot_desc_dict, tasks, n_iters=10000, view_lbl=view, sim_data_node=sim_data_node) model, score, epoch = results['model'], results['score'], results[ 'epoch'] # Save the model. split_label = flags.split save_model( model, flags["model_dir"], "{}_pcnna_{}_{}_{}_{}_{:.4f}".format(flags["dataset_name"], view, flags["model_name"], split_label, epoch, score))
def start_fold(sim_data_node, data_dict, flags, hyper_params, prot_desc_dict, tasks, trainer, transformers_dict, tb_writer, view, k=None): data = trainer.data_provider(k, flags, data_dict) model, optimizer, data_loaders, metrics, weighted_loss, n_dist = trainer.initialize( hparams=hyper_params, train_dataset=data["train"], val_dataset=data["val"], test_dataset=data["test"]) if flags["eval"]: trainer.evaluate_model(model[0], flags["model_dir"], flags["eval_model_name"], data_loaders, metrics, transformers_dict, prot_desc_dict, tasks, sim_data_node=sim_data_node) else: # Train the model results = trainer.train(model, optimizer, data_loaders, metrics, weighted_loss, n_dist, transformers_dict, prot_desc_dict, tasks, n_iters=10000, sim_data_node=sim_data_node, tb_writer=tb_writer) model, score, epoch = results['model'], results['score'], results[ 'epoch'] # Save the model. split_label = "warm" if flags["split_warm"] else "cold_target" if flags["cold_target"] else "cold_drug" if \ flags["cold_drug"] else "None" save_model( model, flags["model_dir"], "{}_{}_{}_{}_{}_{:.4f}".format(flags["dataset_name"], view, flags["model_name"], split_label, epoch, score))
def start_fold(sim_data_node, data_dict, flags, hyper_params, prot_desc_dict, tasks, trainer, transformers_dict, view, protein_profile, summary_writer_creator=None, k=None): data = trainer.data_provider(k, flags, data_dict) model, optimizer, data_loaders, metrics = trainer.initialize(hparams=hyper_params, train_dataset=data["train"], val_dataset=data["val"], test_dataset=data["test"], protein_profile=protein_profile) if flags["eval"]: trainer.evaluate_model(model, flags["model_dir"], flags["eval_model_name"], data_loaders, metrics, transformers_dict, prot_desc_dict, tasks, view=view, sim_data_node=sim_data_node) else: # Train the model results = trainer.train(model, optimizer, data_loaders, metrics, transformers_dict, prot_desc_dict, tasks, n_iters=10000, view=view, sim_data_node=sim_data_node, tb_writer=summary_writer_creator) model, score, epoch = results['model'], results['score'], results['epoch'] # Save the model. save_model(model, flags["model_dir"], "{}_{}_{}_{}_{}_{:.4f}".format(flags["dataset_name"], '_'.join(view), flags["model_name"], flags.split, epoch, score))