Exemple #1
0
from nlp.util import config, ets_reader
from nlp.util import utils as U
from nlp.util.w2vEmbReader import W2VEmbReader


import options

def make_abs(path):
    return os.path.abspath(path)

''' get config '''    
parser = options.get_parser()
config_file = 'config/mode.conf'
argv=[]# override config file here
FLAGS = config.get_config(parser=parser, config_file=config_file, argv=argv)
FLAGS.chkpt_dir = make_abs(FLAGS.chkpt_dir)
FLAGS.data_dir = os.path.join(FLAGS.data_dir, FLAGS.item_id)
pprint.pprint(FLAGS)

''' setup checkpoint directory '''
if not os.path.exists(FLAGS.chkpt_dir):
    U.mkdirs(FLAGS.chkpt_dir)
    print('Created checkpoint directory', FLAGS.chkpt_dir)
config.save_local_config(FLAGS)

# ''' setup logger (???) '''
# U.set_logger(FLAGS.chkpt_dir)

''' random seed '''
rand_seed = U.seed_random(FLAGS.seed)
Exemple #2
0
    #     p.add("-a", "--algorithm", type=str, default='rmsprop', help="Optimization algorithm (rmsprop|sgd|adagrad|adadelta|adam|adamax) (default=rmsprop)")
    #     p.add("-l", "--loss", type=str, default='kappa', help="Loss function (mse|kappa|mae) (default=kappa)")
    #     p.add("-v", "--vocab_size", type=int, default=4000, help="Vocab size (default=4000)")
    #     p.add("-c", "--cnn_dim", type=int, default=0, help="CNN output dimension. '0' means no CNN layer (default=0)")
    #     p.add("-w", "--cnn_window_size", type=int, default=3, help="CNN window size. (default=3)")
    #     p.add("--stack", type=int, default=1, help="how deep to stack core RNN")
    #     p.add("--skip_emb_preload", action='store_true', help="Skip preloading embeddings")
    #     p.add("--tokenize_old", action='store_true', help="use old tokenizer")
    #     p.add("--run_mode", type=str, default='train', required=False, help="train/valid")
    #     p.add("--vocab_path", type=str, help="(Optional) The path to the existing vocab file (*.pkl)")
    #     p.add("--skip_init_bias", action='store_true', help="Skip initialization of the last layer bias")

    #     dir_path = os.path.dirname(os.path.realpath(__file__))# get path of this file
    #     p.add("--code_dir", type=str, default=dir_path, required=False, help="The path to the code directory")

    return p


if __name__ == "__main__":

    parser = get_parser()

    config_file = None
    #config_file = 'chkpt/mod1_650-20/model.conf'
    #config_file = 'config/ats.conf'
    config_file = 'config/mode.conf'

    FLAGS = config.get_config(config_file=config_file, parser=parser)

    pprint.pprint(FLAGS)