Exemplo n.º 1
0
    def _build_item_extractions(self, train=True):

        self._add_module(
            "item_vec",
            LatentFactor(
                l2_reg=self._l2_reg,
                init="normal",
                ids=self._get_input("item_id", train=train),
                shape=[self._max_item, self._dim_embed],
                scope="item",
                reuse=not train,
            ),
            train=train,
        )
        self._add_module(
            "item_bias",
            LatentFactor(
                l2_reg=self._l2_reg,
                init="zero",
                ids=self._get_input("item_id", train=train),
                shape=[self._max_item, 1],
                scope="item_bias",
                reuse=not train,
            ),
            train=train,
        )
Exemplo n.º 2
0
    def _build_item_extractions(self, train=True):

        self._add_module(
            "item_vec",
            TemporalLatentFactor(
                l2_reg=self._l2_reg,
                init=self._pretrained_item_embeddings,
                ids=self._get_input("item_id", train=train),
                mlp_dims=self._item_dims,
                shape=[self._max_item, self._dim_embed],
                train=train,
                scope="item",
                reuse=not train,
            ),
            train=train,
        )
        self._add_module(
            "item_bias",
            LatentFactor(
                l2_reg=self._l2_reg,
                init="zero",
                ids=self._get_input("item_id", train=train),
                shape=[self._max_item, 1],
                scope="item_bias",
                reuse=not train,
            ),
            train=train,
        )
Exemplo n.º 3
0
    def _build_user_extractions(self, train=True):

        self._add_module('user_vec',
                         LatentFactor(l2_reg=self._l2_reg,
                                      init='normal',
                                      ids=self._get_input('user_id',
                                                          train=train),
                                      shape=[self._max_user, self._dim_embed],
                                      scope='user',
                                      reuse=not train),
                         train=train)
Exemplo n.º 4
0
    def _build_item_extractions(self, train=True):

        self._add_module('item_vec',
                         LatentFactor(l2_reg=self._l2_reg,
                                      init='normal',
                                      ids=self._get_input('item_id',
                                                          train=train),
                                      shape=[self._max_item, self._dim_embed],
                                      scope='item',
                                      reuse=not train),
                         train=train)
        self._add_module('item_bias',
                         LatentFactor(l2_reg=self._l2_reg,
                                      init='zero',
                                      ids=self._get_input('item_id',
                                                          train=train),
                                      shape=[self._max_item, 1],
                                      scope='item_bias',
                                      reuse=not train),
                         train=train)
Exemplo n.º 5
0
    def _build_user_extractions(self, train=True):

        self._add_module(
            "user_vec",
            LatentFactor(
                l2_reg=self._l2_reg,
                init="normal",
                ids=self._get_input("user_id", train=train),
                shape=[self._max_user, self._dim_embed],
                scope="user",
                reuse=(not train),
            ),
            train=train,
        )
Exemplo n.º 6
0
    def _build_item_extractions(self, train=True):

        self._add_module('item_vec',
                         TemporalLatentFactor(
                             l2_reg=self._l2_reg,
                             init=self._pretrained_item_embeddings,
                             ids=self._get_input('item_id', train=train),
                             mlp_dims=self._item_dims,
                             shape=[self._max_item, self._dim_embed],
                             train=train,
                             scope='item',
                             reuse=not train),
                         train=train)
        self._add_module('item_bias',
                         LatentFactor(l2_reg=self._l2_reg,
                                      init='zero',
                                      ids=self._get_input('item_id',
                                                          train=train),
                                      shape=[self._max_item, 1],
                                      scope='item_bias',
                                      reuse=not train),
                         train=train)
Exemplo n.º 7
0
    def _build_item_extractions(self, train=True):

        if train:
            self._add_module(
                'p_item_lf',
                LatentFactor(
                    init='normal',
                    l2_reg=self._l2_reg,
                    ids=self._get_input('p_item_id'),
                    shape=[self._max_item, self._dim_embed - self._dim_ve],
                    scope='item',
                    reuse=False))
            self._add_module(
                'p_item_vf',
                MultiLayerFC(in_tensor=self._get_input('p_item_vfeature'),
                             dims=[self._dim_ve],
                             scope='item_MLP',
                             reuse=False))
            self._add_module(
                'p_item_bias',
                LatentFactor(l2_reg=self._l2_reg,
                             init='zero',
                             ids=self._get_input('p_item_id'),
                             shape=[self._max_item, 1],
                             scope='item_bias',
                             reuse=False))
            self._add_module(
                'n_item_lf',
                LatentFactor(
                    init='normal',
                    l2_reg=self._l2_reg,
                    ids=self._get_input('n_item_id'),
                    shape=[self._max_item, self._dim_embed - self._dim_ve],
                    scope='item',
                    reuse=True))
            self._add_module(
                'n_item_vf',
                MultiLayerFC(in_tensor=self._get_input('n_item_vfeature'),
                             dims=[self._dim_ve],
                             scope='item_MLP',
                             reuse=True))
            self._add_module(
                'n_item_bias',
                LatentFactor(l2_reg=self._l2_reg,
                             init='zero',
                             ids=self._get_input('n_item_id'),
                             shape=[self._max_item, 1],
                             scope='item_bias',
                             reuse=True))
        else:
            self._add_module('item_lf',
                             LatentFactor(init='normal',
                                          l2_reg=self._l2_reg,
                                          ids=self._get_input('item_id',
                                                              train=train),
                                          shape=[
                                              self._max_item,
                                              self._dim_embed - self._dim_ve
                                          ],
                                          scope='item',
                                          reuse=True),
                             train=False)
            self._add_module('item_vf',
                             MultiLayerFC(in_tensor=self._get_input(
                                 'item_vfeature', train=train),
                                          dims=[self._dim_ve],
                                          scope='item_MLP',
                                          reuse=True),
                             train=False)
            self._add_module('item_bias',
                             LatentFactor(l2_reg=self._l2_reg,
                                          init='zero',
                                          ids=self._get_input('item_id',
                                                              train=train),
                                          shape=[self._max_item, 1],
                                          scope='item_bias',
                                          reuse=True),
                             train=False)
Exemplo n.º 8
0
    def _build_item_extractions(self, train=True):

        if train:
            self._add_module(
                "p_item_lf",
                LatentFactor(
                    init="normal",
                    l2_reg=self._l2_reg,
                    ids=self._get_input("p_item_id"),
                    shape=[self._max_item, self._dim_embed - self._dim_ve],
                    scope="item",
                    reuse=False,
                ),
            )
            self._add_module(
                "p_item_vf",
                MultiLayerFC(
                    in_tensor=self._get_input("p_item_vfeature"),
                    dims=[self._dim_ve],
                    scope="item_MLP",
                    reuse=False,
                ),
            )
            self._add_module(
                "p_item_bias",
                LatentFactor(
                    l2_reg=self._l2_reg,
                    init="zero",
                    ids=self._get_input("p_item_id"),
                    shape=[self._max_item, 1],
                    scope="item_bias",
                    reuse=False,
                ),
            )
            self._add_module(
                "n_item_lf",
                LatentFactor(
                    init="normal",
                    l2_reg=self._l2_reg,
                    ids=self._get_input("n_item_id"),
                    shape=[self._max_item, self._dim_embed - self._dim_ve],
                    scope="item",
                    reuse=True,
                ),
            )
            self._add_module(
                "n_item_vf",
                MultiLayerFC(
                    in_tensor=self._get_input("n_item_vfeature"),
                    dims=[self._dim_ve],
                    scope="item_MLP",
                    reuse=True,
                ),
            )
            self._add_module(
                "n_item_bias",
                LatentFactor(
                    l2_reg=self._l2_reg,
                    init="zero",
                    ids=self._get_input("n_item_id"),
                    shape=[self._max_item, 1],
                    scope="item_bias",
                    reuse=True,
                ),
            )
        else:
            self._add_module(
                "item_lf",
                LatentFactor(
                    init="normal",
                    l2_reg=self._l2_reg,
                    ids=self._get_input("item_id", train=train),
                    shape=[self._max_item, self._dim_embed - self._dim_ve],
                    scope="item",
                    reuse=True,
                ),
                train=False,
            )
            self._add_module(
                "item_vf",
                MultiLayerFC(
                    in_tensor=self._get_input("item_vfeature", train=train),
                    dims=[self._dim_ve],
                    scope="item_MLP",
                    reuse=True,
                ),
                train=False,
            )
            self._add_module(
                "item_bias",
                LatentFactor(
                    l2_reg=self._l2_reg,
                    init="zero",
                    ids=self._get_input("item_id", train=train),
                    shape=[self._max_item, 1],
                    scope="item_bias",
                    reuse=True,
                ),
                train=False,
            )