示例#1
0
 def item_graph(subgraph):
     _, subgraph['seq_vec'] = embedding_layer.apply(
         l2_reg=l2_reg_embed,
         init='normal',
         id_=subgraph['seq_item_id'],
         shape=[total_items, dim_item_embed],
         subgraph=subgraph,
         scope='item')
示例#2
0
 def train_itemgraph(subgraph):
     _, item_embedded_tensor_1 = embedding_layer.apply(l2_reg=l2_reg,
         init="normal",
         id_=subgraph["item_id_1"],
         shape=[total_item_num, embedding_dim],
         subgraph=subgraph,
         scope="ItemEmbedding")
     _, item_embedded_tensor_2 = embedding_layer.apply(l2_reg=l2_reg,
         init="normal",
         id_=subgraph["item_id_2"],
         shape=[total_item_num, embedding_dim],
         subgraph=subgraph,
         scope="ItemEmbedding")
     subgraph["item_vec_1"] = concatenate.apply([
         subgraph["item_meta_vec_1"], subgraph["item_stat_vec_1"], item_embedded_tensor_1])
     subgraph["item_vec_2"] = concatenate.apply([
         subgraph["item_meta_vec_2"], subgraph["item_stat_vec_2"], item_embedded_tensor_2])
     pass
示例#3
0
 def serve_itemgraph(subgraph):
     _, item_embedded_tensor = embedding_layer.apply(l2_reg=l2_reg,
         init="normal",
         id_=subgraph["item_id"],
         shape=[total_item_num, embedding_dim],
         subgraph=subgraph,
         scope="ItemEmbedding")
     subgraph["item_vec"] = concatenate.apply([
         subgraph["item_meta_vec"], subgraph["item_stat_vec"], item_embedded_tensor])
     pass
示例#4
0
 def usergraph(subgraph):
     _, item_embedded_tensor = embedding_layer.apply(l2_reg=l2_reg,
         init="normal",
         id_=subgraph["user_history_vec"],
         shape=[total_item_num, embedding_dim],
         subgraph=subgraph,
         scope="ItemEmbedding") # shaped [-1, fea_user_history_dim, embedding_dim]
     user_history_repr = variable_average.apply(
         sequence=item_embedded_tensor, seq_len=subgraph["user_history_len"]) # shaped [-1, 1, embedding_dim]
     subgraph["user_vec"] = concatenate.apply([
         subgraph["user_demography_vec"], subgraph["user_stat_vec"], user_history_repr])
     pass