Esempio n. 1
0
def read_pkls(hpconfigs=hpconfigs, name_pattern='hpconfig_(no_\w+)'):
    root_dirs = {}
    accuracies = {}
    max_epoch_count = 0
    min_epoch_count = 10000000

    for hpconfig in hpconfigs:
        try:
            tasks = re.match(name_pattern, hpconfig)
            if tasks:
                tasks = tasks.group(1)
            else:
                tasks = 'main'
            root_dirs[tasks] = initialize_task(hpconfig + '.py')
            accuracies[tasks] = pickle.load(
                open(
                    '{}/results/metrics/main.accuracy.pkl'.format(
                        root_dirs[tasks]), 'rb'))

            if len(accuracies[tasks]) < min_epoch_count:
                min_epoch_count = len(accuracies[tasks])
                print('min_epoch_count: {}'.format(min_epoch_count))

            if len(accuracies[tasks]) > max_epoch_count:
                max_epoch_count = len(accuracies[tasks])
                print('max_epoch_count: {}'.format(max_epoch_count))
        except:
            print('{} not found'.format(tasks))

    return accuracies, min_epoch_count, max_epoch_count
Esempio n. 2
0
def read_pkls():
    
    accuracies = {}
    max_epoch_count = 0
    min_epoch_count = 10000000
    
    hpconfig = 'hpconfig'
    HPCONFIG = importlib.__import__(hpconfig)
    tasks = '-'.join(str(i) for i in HPCONFIG.CONFIG.tasks)
    root_dir= initialize_task(hpconfig + '.py')
    print('root_dir: {}'.format(root_dir))
    for filename in glob.glob('{}/results/metrics/*.accuracy.pkl'.format(root_dir)):
        try:
            task = os.path.basename(filename).split('.')[0]
            accuracies[task] = pickle.load(
                open(filename,
                     'rb')
            )

            if len(accuracies[task]) < min_epoch_count:
                min_epoch_count = len(accuracies[task])
                print('min_epoch_count: {}'.format(min_epoch_count))


            if len(accuracies[task]) > max_epoch_count:
                max_epoch_count = len(accuracies[task])
                print('max_epoch_count: {}'.format(max_epoch_count))
        except:
            print('{} not found'.format(filename))

    return accuracies, min_epoch_count, max_epoch_count
def read_pkls(hpconfigs=hpconfigs):
    root_dirs = {}
    accuracies = {}
    max_epoch_count = 0
    min_epoch_count = 10000000

    for hpconfig in hpconfigs:
        try:
            HPCONFIG = importlib.__import__(hpconfig)
            if len(HPCONFIG.CONFIG.tasks) > 1:
                tasks = 'main'
            else:
                tasks = task_names[HPCONFIG.CONFIG.tasks[0]]

            root_dirs[tasks] = initialize_task(hpconfig + '.py')
            accuracies[tasks] = pickle.load(
                open('{}/results/metrics/main.accuracy.pkl'.format(root_dirs[tasks]),
                     'rb')
            )

            if len(accuracies[tasks]) < min_epoch_count:
                min_epoch_count = len(accuracies[tasks])
                print('min_epoch_count: {}'.format(min_epoch_count))

            if len(accuracies[tasks]) > max_epoch_count:
                max_epoch_count = len(accuracies[tasks])
                print('max_epoch_count: {}'.format(max_epoch_count))
        except:
            print('{} not found'.format(tasks))
            
    return accuracies, min_epoch_count, max_epoch_count
def read_pkls(hpconfigs=hpconfigs):
    root_dirs = defaultdict(list)
    accuracies = defaultdict(list)
    losses = defaultdict(list)

    for hpconfig in hpconfigs:
        try:
            hpconfig = PREFIX + '.' + hpconfig
            HPCONFIG = importlib.import_module(hpconfig)
            model = re.search('.*hpconfig_(\w+)', hpconfig)
            model = model.group(1)

            log.info('hpconfig -- {}'.format(hpconfig))

            for rd in run_dirs:
                rd = initialize_task(hpconfig.replace('.', '/') + '.py', rd)
                root_dirs[model].append(rd)
                log.info(' rd: {}'.format(rd))

                f = '{}/results/metrics/{}.test_accuracy.pkl'.format(
                    rd, HPCONFIG.CONFIG.model_name)

                accuracies[model].append(pickle.load(open(f, 'rb')))

                f = '{}/results/metrics/{}.test_loss.pkl'.format(
                    rd, HPCONFIG.CONFIG.model_name)

                losses[model].append(pickle.load(open(f, 'rb')))
            """
            if len(accuracies[model]) < EPOCH_COUNT_MIN:
                EPOCH_COUNT_MIN = len(accuracies[model])
                print('min_epoch_count: {}'.format( EPOCH_COUNT_MIN))

            if len(accuracies[model]) > EPOCH_COUNT_MAX:
                EPOCH_COUNT_MAX = len(accuracies[model])
                print('max_epoch_count: {}'.format(EPOCH_COUNT_MAX))
            """
        except:
            log.exception('{} not found'.format(model))

    return root_dirs, accuracies, losses, EPOCH_COUNT_MIN, EPOCH_COUNT_MAX
Esempio n. 5
0
                                action='store_true',
                                dest='show_plot')
    predict_parser.add_argument('--save-plot',
                                action='store_true',
                                dest='save_plot')
    predict_parser.add_argument('--uniqueness', default=50, dest='beam_width')

    args = parser.parse_args()
    print(args)
    if args.log_filter:
        log.addFilter(CMDFilter(args.log_filter))

    ########################################################################################
    # anikattu initialization for directory structure and so on
    ########################################################################################
    ROOT_DIR = initialize_task(args.hpconfig, args.prefix_dir)

    sys.path.append('.')
    print(sys.path)
    HPCONFIG = importlib.__import__(args.hpconfig.replace('.py', ''))
    config.HPCONFIG = HPCONFIG.CONFIG
    config.ROOT_DIR = ROOT_DIR
    config.NAME = SELF_NAME
    print('====================================')
    print(ROOT_DIR)
    print('====================================')

    ########################################################################################
    # flush and load dataset or restore pickle file
    ########################################################################################
    if config.CONFIG.flush:
Esempio n. 6
0
from utilz import Sample, load_task_data
from utilz import PAD, word_tokenize
from utilz import VOCAB
from utilz import train, plot_attn, predict_batchop
from utilz import load_task1_data

from model import Net

SELF_NAME = os.path.basename(__file__).replace('.py', '')

import sys
import pickle
if __name__ == '__main__':

    ROOT_DIR = initialize_task(SELF_NAME)

    print('====================================')
    print(ROOT_DIR)
    print('====================================')

    if config.CONFIG.flush:
        log.info('flushing...')
        dataset = load_task6_data()
        pickle.dump(dataset, open('{}__cache.pkl'.format(SELF_NAME), 'wb'))
    else:
        dataset = pickle.load(open('{}__cache.pkl'.format(SELF_NAME), 'rb'))

    log.info('dataset size: {}'.format(len(dataset.trainset)))
    log.info('dataset[:10]: {}'.format(pformat(dataset.trainset[0])))
Esempio n. 7
0
        help='''starts a cli interface for running predictions 
                                in inputs with best model from last training run'''
    )
    predict_parser.add_argument('--predict', default='predict', dest='task')
    predict_parser.add_argument('--show-plot',
                                action='store_true',
                                dest='show_plot')
    predict_parser.add_argument('--save-plot',
                                action='store_true',
                                dest='save_plot')
    args = parser.parse_args()
    print(args)
    if args.log_filter:
        log.addFilter(CMDFilter(args.log_filter))

    ROOT_DIR = initialize_task(args.hpconfig)

    sys.path.append('.')
    print(sys.path)
    HPCONFIG = importlib.__import__(args.hpconfig.replace('.py', ''))
    config.HPCONFIG = HPCONFIG.CONFIG
    config.ROOT_DIR = ROOT_DIR
    config.NAME = SELF_NAME
    print('====================================')
    print(ROOT_DIR)
    print('====================================')

    if config.CONFIG.flush:
        log.info('flushing...')
        dataset = load_data(config, filename=config.HPCONFIG.dataset_path)
        pickle.dump(dataset,
Esempio n. 8
0
                                               default='dump-cosine-similarity',
                                               dest='task')

    
    predict_parser = subparsers.add_parser('predict',
                                help='''starts a cli interface for running predictions 
                                in inputs with best model from last training run''')
    predict_parser.add_argument('--predict', default='predict', dest='task')
    predict_parser.add_argument('--show-plot', action='store_true', dest='show_plot')
    predict_parser.add_argument('--save-plot', action='store_true',  dest='save_plot')
    args = parser.parse_args()
    print(args)
    if args.log_filter:
        log.addFilter(CMDFilter(args.log_filter))

    ROOT_DIR = initialize_task(args.hpconfig, prefix=args.results_dir)

    sys.path.append('.')
    print(sys.path)

    args.hpconfig = args.hpconfig.replace('/', '.').replace('.py', '')
    modpath = args.hpconfig.split('.')
    pkg, mod = '.'.join(modpath[:-1]), modpath[-1]
    
    HPCONFIG = importlib.import_module(args.hpconfig)
    config.HPCONFIG = HPCONFIG.CONFIG
    config.ROOT_DIR = ROOT_DIR
    config.NAME = SELF_NAME
    print('====================================')
    print(ROOT_DIR)
    print('====================================')
Esempio n. 9
0
                                action='store_true',
                                dest='show_plot')
    predict_parser.add_argument('--save-plot',
                                action='store_true',
                                dest='save_plot')

    args = parser.parse_args()
    print(args)
    if args.log_filter:
        log.addFilter(CMDFilter(args.log_filter))

    ########################################################################################
    # anikattu initialization for directory structure and so on
    ########################################################################################
    ROOT_DIR = initialize_task(args.hpconfig,
                               args.prefix_dir,
                               base_hpconfig=args.base_hpconfig)

    sys.path.append('.')
    print(sys.path)
    HPCONFIG = importlib.__import__(args.hpconfig.replace('.py', ''))
    config.HPCONFIG = HPCONFIG.CONFIG
    config.ROOT_DIR = ROOT_DIR
    config.NAME = SELF_NAME
    print('====================================')
    print(ROOT_DIR)
    print('====================================')

    ########################################################################################
    # flush and load dataset or restore pickle file
    ########################################################################################