"Usage: predict.py <config_name> <n_tta_iterations> <average: arithmetic|geometric>" ) config_name = sys.argv[1] n_tta_iterations = int(sys.argv[2]) if len(sys.argv) >= 3 else 100 mean = sys.argv[3] if len(sys.argv) >= 4 else 'geometric' print 'Make %s tta predictions for %s set using %s mean' % ( n_tta_iterations, "valid and test", mean) metadata_dir = utils.get_dir_path('train', METADATA_PATH) metadata_path = utils.find_model_metadata(metadata_dir, config_name) metadata = utils.load_pkl(metadata_path) assert config_name == metadata['configuration'] if 'subconfiguration' in metadata: set_subconfiguration(metadata['subconfiguration']) set_configuration(config_name) # predictions paths jonas_prediction_path = PREDICTIONS_PATH + '/ira_%s.pkl' % config().__name__ prediction_dir = utils.get_dir_path('predictions', METADATA_PATH) valid_prediction_path = prediction_dir + "/%s-%s-%s-%s.pkl" % ( metadata['experiment_id'], 'valid', n_tta_iterations, mean) test_prediction_path = prediction_dir + "/%s-%s-%s-%s.pkl" % ( metadata['experiment_id'], 'test', n_tta_iterations, mean) # submissions paths submission_dir = utils.get_dir_path('submissions', METADATA_PATH) submission_path = submission_dir + "/%s-%s-%s-%s.csv" % ( metadata['experiment_id'], 'test', n_tta_iterations, mean)
import lasagne as nn import utils import buffering import utils_heart from configuration import config, set_configuration, set_subconfiguration from pathfinder import METADATA_PATH if not (len(sys.argv) < 3): sys.exit("Usage: predict.py <metadata_path>") metadata_path = sys.argv[1] metadata_dir = utils.get_dir_path('train', METADATA_PATH) metadata = utils.load_pkl(metadata_dir + '/%s' % metadata_path) config_name = metadata['configuration'] if 'subconfiguration' in metadata: set_subconfiguration(metadata['subconfiguration']) set_configuration(config_name) # predictions paths prediction_dir = utils.get_dir_path('predictions', METADATA_PATH) prediction_path = prediction_dir + "/%s.pkl" % metadata['experiment_id'] prediction_mu_std_path = prediction_dir + "/%s_mu_sigma.pkl" % metadata['experiment_id'] print "Build model" model = config().build_model() all_layers = nn.layers.get_all_layers(model.l_top) all_params = nn.layers.get_all_params(model.l_top) num_params = nn.layers.count_params(model.l_top) print ' number of parameters: %d' % num_params nn.layers.set_all_param_values(model.l_top, metadata['param_values'])
if not (3 <= len(sys.argv) <= 5): sys.exit("Usage: predict.py <config_name> <n_tta_iterations> <average: arithmetic|geometric>") config_name = sys.argv[1] n_tta_iterations = int(sys.argv[2]) if len(sys.argv) >= 3 else 100 mean = sys.argv[3] if len(sys.argv) >= 4 else "geometric" print "Make %s tta predictions for %s set using %s mean" % (n_tta_iterations, "valid and test", mean) metadata_dir = utils.get_dir_path("train", METADATA_PATH) metadata_path = utils.find_model_metadata(metadata_dir, config_name) metadata = utils.load_pkl(metadata_path) assert config_name == metadata["configuration"] if "subconfiguration" in metadata: set_subconfiguration(metadata["subconfiguration"]) set_configuration(config_name) # predictions paths jonas_prediction_path = PREDICTIONS_PATH + "/ira_%s.pkl" % config().__name__ prediction_dir = utils.get_dir_path("predictions", METADATA_PATH) valid_prediction_path = prediction_dir + "/%s-%s-%s-%s.pkl" % ( metadata["experiment_id"], "valid", n_tta_iterations, mean, ) test_prediction_path = prediction_dir + "/%s-%s-%s-%s.pkl" % (metadata["experiment_id"], "test", n_tta_iterations, mean) # submissions paths submission_dir = utils.get_dir_path("submissions", METADATA_PATH)
from configuration import config, set_configuration, set_subconfiguration import pathfinder if len(sys.argv) < 2: sys.exit("Usage: train.py <meta_configuration_name>") config_name = sys.argv[1] subconfig_name = config_name.replace('meta_', '') metadata_dir = utils.get_dir_path('train', pathfinder.METADATA_PATH) submodel_metadata_path = utils.find_model_metadata(metadata_dir, subconfig_name) submodel_metadata = utils.load_pkl(submodel_metadata_path) assert subconfig_name == submodel_metadata['configuration'] set_subconfiguration(subconfig_name) set_configuration(config_name) expid = utils.generate_expid(config_name) print() print("Experiment ID: %s" % expid) print() # meta metadata and logs paths metadata_path = metadata_dir + '/%s.pkl' % expid logs_dir = utils.get_dir_path('logs', pathfinder.METADATA_PATH) sys.stdout = logger.Logger(logs_dir + '/%s.log' % expid) print('Build model') model = config().build_model() all_layers = nn.layers.get_all_layers(model.l_top)
import buffering from configuration import config, set_configuration, set_subconfiguration import pathfinder if len(sys.argv) < 2: sys.exit("Usage: train.py <meta_configuration_name>") config_name = sys.argv[1] subconfig_name = config_name.replace('meta_', '') metadata_dir = utils.get_dir_path('train', pathfinder.METADATA_PATH) submodel_metadata_path = utils.find_model_metadata(metadata_dir, subconfig_name) submodel_metadata = utils.load_pkl(submodel_metadata_path) assert subconfig_name == submodel_metadata['configuration'] set_subconfiguration(subconfig_name) set_configuration(config_name) expid = utils.generate_expid(config_name) print print "Experiment ID: %s" % expid print # meta metadata and logs paths metadata_path = metadata_dir + '/%s.pkl' % expid logs_dir = utils.get_dir_path('logs', pathfinder.METADATA_PATH) sys.stdout = logger.Logger(logs_dir + '/%s.log' % expid) print 'Build model' model = config().build_model() all_layers = nn.layers.get_all_layers(model.l_top)