<reponame>mohammadKhalifa/Bi-lateral-multiperspective-matching
import os
import json
import logging
import argparse
import torch
from model.model import *
from model.loss import *
from model.metric import *
from data_loader import MnistDataLoader, BLMPMDataLoader
from trainer import Trainer
from logger import Logger

logging.basicConfig(level=logging.INFO, format='')


def main(config, resume):
    train_logger = Logger()
    data_loader = BLMPMDataLoader(config)
    val_data_loader = data_loader.split_validation()
    assert val_data_loader is not None
    model = eval(config['arch'])(config['model'])
    model.cuda()
    
    for name, param in model.named_parameters():
        if param.requires_grad:
            print (name)

    #model.multiperspective_matching(a,a- 10,W)
    #model(p, q, embeddings)
    
    model.summary()
    loss = eval(config['loss'])
    metrics = [eval(metric) for metric in config['metrics']]

    trainer = Trainer(model, loss, metrics,
                      resume=resume,
                      config=config,
                      data_loader=data_loader,
                      valid_data_loader=val_data_loader,
                      train_logger=train_logger)

    trainer.train()



if __name__ == '__main__':
    logger = logging.getLogger()

    parser = argparse.ArgumentParser(description='PyTorch Template')
    parser.add_argument('-c', '--config', default='None', type=str,
                        help='config file path (default: None)')
    parser.add_argument('-r', '--resume', default=None, type=str,
                        help='path to latest checkpoint (default: None)')

    args = parser.parse_args()

    config = None

    if args.resume is not None:
        if args.config is not None:
            logger.warning('Warning: --config overridden by --resume')
        config = torch.load(args.resume)['config']
    elif args.config is not None:
        config = json.load(open(args.config))
        #path = os.path.join(config['trainer']['save_dir'], config['name'])
        #assert not os.path.exists(path), "Path {} already exists!".format(path)
    assert config is not None

    main(config, args.resume)

import os
import json
import logging
import argparse
import torch
from model.model import *
from model.loss import *
from model.metric import *
from data_loader import MnistDataLoader, BLMPMDataLoader
from trainer import Trainer
from logger import Logger

logging.basicConfig(level=logging.INFO, format='')


def main(config, resume):
    train_logger = Logger()
    data_loader = BLMPMDataLoader(config)
    val_data_loader = data_loader.split_validation()
    assert val_data_loader is not None
    model = eval(config['arch'])(config['model'])
    model.cuda()
    
    for name, param in model.named_parameters():
        if param.requires_grad:
            print (name)

    #model.multiperspective_matching(a,a- 10,W)
    #model(p, q, embeddings)
    
    model.summary()
    loss = eval(config['loss'])
    metrics = [eval(metric) for metric in config['metrics']]

    trainer = Trainer(model, loss, metrics,
                      resume=resume,
                      config=config,
                      data_loader=data_loader,
                      valid_data_loader=val_data_loader,
                      train_logger=train_logger)

    trainer.train()



if __name__ == '__main__':
    logger = logging.getLogger()

    parser = argparse.ArgumentParser(description='PyTorch Template')
    parser.add_argument('-c', '--config', default='None', type=str,
                        help='config file path (default: None)')
    parser.add_argument('-r', '--resume', default=None, type=str,
                        help='path to latest checkpoint (default: None)')

    args = parser.parse_args()

    config = None

    if args.resume is not None:
        if args.config is not None:
            logger.warning('Warning: --config overridden by --resume')
        config = torch.load(args.resume)['config']
    elif args.config is not None:
        config = json.load(open(args.config))
        #path = os.path.join(config['trainer']['save_dir'], config['name'])
        #assert not os.path.exists(path), "Path {} already exists!".format(path)
    assert config is not None

    main(config, args.resume)
#model.multiperspective_matching(a,a- 10,W) #model(p, q, embeddings) #path = os.path.join(config['trainer']['save_dir'], config['name']) #assert not os.path.exists(path), "Path {} already exists!".format(path)