Example #1
0
word_embeddings_file = os.path.join(data_path, "word_embeddings_5w_100.npy")
entity_embeddings_file = os.path.join(data_path,
                                      "entity_embeddings_5w_100.npy")

train_path = os.path.join(data_path, "train")
valid_path = os.path.join(data_path, "valid")
test_path = os.path.join(data_path, "test")

yaml_file = maybe_download(
    url=
    "https://recodatasets.blob.core.windows.net/deeprec/deeprec/dkn/dkn_MINDsmall.yaml",
    work_directory=data_path)
hparams = prepare_hparams(yaml_file,
                          news_feature_file=news_feature_file,
                          user_history_file=user_history_file,
                          wordEmb_file=word_embeddings_file,
                          entityEmb_file=entity_embeddings_file,
                          epochs=epochs,
                          history_size=history_size,
                          batch_size=batch_size)

hparams.save_model = True
hparams.show_step = 5000
hparams.MODEL_DIR = 'para'

model = DKN(hparams, DKNTextIterator)
model.load_model('./para/epoch_5')

# model.run_test(valid_file, 14085557, save_model=True, validate=True)
model.run_test(test_file, 10388965, save_model=False, validate=True)
Example #2
0
entity_embeddings_file = os.path.join(data_path,
                                      "entity_embeddings_5w_100.npy")

train_path = os.path.join(data_path, "train")
valid_path = os.path.join(data_path, "valid")
test_path = os.path.join(data_path, "test")

yaml_file = maybe_download(
    url=
    "https://recodatasets.blob.core.windows.net/deeprec/deeprec/dkn/dkn_MINDsmall.yaml",
    work_directory=data_path)
hparams = prepare_hparams(yaml_file,
                          news_feature_file=news_feature_file,
                          user_history_file=user_history_file,
                          wordEmb_file=word_embeddings_file,
                          entityEmb_file=entity_embeddings_file,
                          epochs=epochs,
                          history_size=history_size,
                          batch_size=batch_size)

hparams.save_model = True
hparams.show_step = 5000
hparams.MODEL_DIR = 'para'

model = DKN(hparams, DKNTextIterator)
model.load_model('./para/epoch_4')

# model.run_test(valid_file, 14085557, save_model=True, validate=True)
model.run_test(test_file, 93115001, save_model=True, validate=False)
# model.run_eval(test_file)