-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtrain-predict-MIXED-strategy.py
42 lines (34 loc) · 1.3 KB
/
train-predict-MIXED-strategy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import tensorflow as tf
from tensorflow import keras
from numpy import loadtxt
from keras.models import Sequential
from keras.layers import Dense
import os
from utilities.utils import read_ratings,read_graph_embeddings,read_bert_embedding,matching_Bert_Graph
from models.model2_conf2_strategy import run_model
import logging
import sys
if __name__ == "__main__":
logging.basicConfig(format="%(message)s", level=logging.INFO)
logger = logging.getLogger(__name__)
if len(sys.argv) != 5:
logger.error("Invalid number of parameters.")
exit(-1)
bert_user_source = sys.argv[1]
bert_item_source = sys.argv[2]
graph_source = sys.argv[3]
dest = sys.argv[4]
prediction_dest = sys.argv[5]
print(bert_user_source)
print(bert_item_source)
print(graph_source)
print(dest)
print(prediction_dest)
user, item, rating = read_ratings('datasets/movielens/train2id.tsv')
graph_embeddings = read_graph_embeddings(graph_source)
user_bert_embeddings = read_bert_embedding(bert_user_source)
item_bert_embeddings = read_bert_embedding(bert_item_source)
X_graph, X_bert, dim_graph, dim_bert, y = matching_Bert_Graph(user,item,rating,graph_embeddings,user_bert_embeddings,item_bert_embeddings)
model = run_model(X_graph,X_bert,dim_graph,dim_bert,y,epochs=25,batch_size=1536)
# creates a HDF5 file 'model.h5'
model.save(dest + 'model.h5')