Example #1
0
    def __init__(self, k = 10):
        flag = "ntm_model.new_trained.freq=100.word=22548"
        conf = Config(flag, "full", 200)
        print(flag)
        print(k)


        self.k = k
        self.data_path = "".join((home, "/Data/yelp/output/raw_review_restaurant.json"))
        # generate dataset
        self.train_path = "train80p1.json"
        self.test_path = "test80p1.json"
        self.prod_vector = conf.path_doc_w2c
        self.prod2idx = {}
        self.idx2prod = []
        self.user2idx = {}
        self.idx2user = []
Example #2
0
    lr = float(args[5])
    print(args)
    os.environ['MKL_NUM_THREADS'] = str(n_processer)
    os.environ['GOTO_NUM_THREADS'] = str(n_processer)
    os.environ['OMP_NUM_THREADS'] = str(n_processer)
    os.environ['THEANO_FLAGS'] = 'device=cpu,blas.ldflags=-lblas -lgfortran'

    import os

    os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"   # see issue #152
    os.environ["CUDA_VISIBLE_DEVICES"] = "0,1,2,3"
    config = tf.ConfigProto(log_device_placement=False, allow_soft_placement=True)
    config.gpu_options.allow_growth = True
    config.gpu_options.per_process_gpu_memory_fraction = 1

    conf = Config(flag, args[2], int(args[3]))
    print(flag)
    print(theano.config.openmp)

    # get data
    dp = DataProvider(conf)
    model, word_embed, prod_embed, tag_embed = build_attr_model(dp)

    if os.path.exists(conf.path_checkpoint):
        print("load previous checker")
        model.load_weights(conf.path_checkpoint)


    dp.generate_init()
    model.fit_generator(generator=dp.generate_data(batch_size=conf.batch_size), nb_worker=n_processer,
                        nb_epoch=conf.n_epoch, samples_per_epoch=int(np.ceil(conf.sample_per_epoch / conf.batch_size)),