Beispiel #1
0
    def __init__(self, args):
        super(Net, self).__init__()
        self._act = get_activation(args.model_activation)
        self.encoder = nn.ModuleList()
        self.encoder.append(
            GCMCLayer(args.rating_vals,
                      args.src_in_units,
                      args.dst_in_units,
                      args.gcn_agg_units,
                      args.gcn_out_units,
                      args.gcn_dropout,
                      args.gcn_agg_accum,
                      agg_act=self._act,
                      share_user_item_param=args.share_param,
                      device=args.device))
        self.gcn_agg_accum = args.gcn_agg_accum
        self.rating_vals = args.rating_vals
        self.device = args.device
        self.gcn_agg_units = args.gcn_agg_units
        self.src_in_units = args.src_in_units
        for i in range(1, args.layers):
            if args.gcn_agg_accum == 'stack':
                gcn_out_units = args.gcn_out_units * len(args.rating_vals)
            else:
                gcn_out_units = args.gcn_out_units
            self.encoder.append(
                GCMCLayer(args.rating_vals,
                          args.gcn_out_units,
                          args.gcn_out_units,
                          gcn_out_units,
                          args.gcn_out_units,
                          args.gcn_dropout - i * 0.1,
                          args.gcn_agg_accum,
                          agg_act=self._act,
                          share_user_item_param=args.share_param,
                          ini=False,
                          device=args.device))

        if args.decoder == "Bi":
            self.decoder = BiDecoder(
                in_units=args.gcn_out_units,  #* args.layers,
                num_classes=len(args.rating_vals),
                num_basis=args.gen_r_num_basis_func)
            '''
            self.decoder2 = MLPDecoder(in_units= args.gcn_out_units * 2,
                                     num_classes=len(args.rating_vals),
                                     num_basis=args.gen_r_num_basis_func)
            '''
        elif args.decoder == "MLP":
            if args.loss_func == "CE":
                num_classes = len(args.rating_vals)
            else:
                num_classes = 1
            self.decoder = MLPDecoder(in_units=args.gcn_out_units *
                                      args.layers,
                                      num_classes=num_classes,
                                      num_basis=args.gen_r_num_basis_func)
        self.rating_vals = args.rating_vals
    def __init__(self, args, dev_id):
        super(Net, self).__init__()
        self._act = get_activation(args.model_activation)
        self.encoder = nn.ModuleList()
        self.encoder.append(
            GCMCLayer(args.rating_vals,
                      args.src_in_units,
                      args.dst_in_units,
                      args.gcn_agg_units,
                      args.gcn_out_units,
                      args.gcn_dropout,
                      args.gcn_agg_accum,
                      agg_act=self._act,
                      share_user_item_param=args.share_param,
                      device=dev_id))

        self.rating_vals = args.rating_vals

        self.gcn_agg_accum = args.gcn_agg_accum
        self.rating_vals = args.rating_vals
        self.device = dev_id
        self.gcn_agg_units = args.gcn_agg_units
        self.src_in_units = args.src_in_units
        self.batch_size = args.minibatch_size
        for i in range(1, args.layers):
            if args.gcn_agg_accum == 'stack':
                gcn_out_units = args.gcn_out_units * len(args.rating_vals)
            else:
                gcn_out_units = args.gcn_out_units
            self.encoder.append(
                GCMCLayer(args.rating_vals,
                          args.gcn_out_units,
                          args.gcn_out_units,
                          gcn_out_units,
                          args.gcn_out_units,
                          args.gcn_dropout - i * 0.1,
                          args.gcn_agg_accum,
                          agg_act=self._act,
                          share_user_item_param=args.share_param,
                          ini=False,
                          device=dev_id))

        if args.mix_cpu_gpu and args.use_one_hot_fea:
            # if use_one_hot_fea, user and movie feature is None
            # W can be extremely large, with mix_cpu_gpu W should be stored in CPU
            self.encoder.partial_to(dev_id)
        else:
            self.encoder.to(dev_id)

        self.decoder = BiDecoder(in_units=args.gcn_out_units,
                                 num_classes=len(args.rating_vals),
                                 num_basis=args.gen_r_num_basis_func)
        self.decoder.to(dev_id)
Beispiel #3
0
 def __init__(self, args):
     super(Net, self).__init__()
     self._act = get_activation(args.model_activation)
     self.encoder = GCMCLayer(args.rating_vals,
                              args.src_in_units,
                              args.dst_in_units,
                              args.gcn_agg_units,
                              args.gcn_out_units,
                              args.gcn_dropout,
                              args.gcn_agg_accum,
                              agg_act=self._act,
                              share_user_item_param=args.share_param)
     self.decoder = BiDecoder(args.rating_vals,
                              in_units=args.gcn_out_units,
                              num_basis_functions=args.gen_r_num_basis_func)
Beispiel #4
0
 def __init__(self, args, **kwargs):
     super(Net, self).__init__(**kwargs)
     self._act = get_activation(args.model_activation)
     with self.name_scope():
         self.encoder = GCMCLayer(src_key=args.src_key,
                                  dst_key=args.dst_key,
                                  src_in_units=args.src_in_units,
                                  dst_in_units=args.dst_in_units,
                                  agg_units=args.gcn_agg_units,
                                  out_units=args.gcn_out_units,
                                  num_links=args.nratings,
                                  dropout_rate=args.gcn_dropout,
                                  agg_accum=args.gcn_agg_accum,
                                  agg_act=args.model_activation,
                                  prefix='enc_')
         if args.gen_r_use_classification:
             self.gen_ratings = BiDecoder(
                 in_units=args.gcn_out_units,
                 out_units=args.nratings,
                 num_basis_functions=args.gen_r_num_basis_func,
                 prefix='gen_rating')
         else:
             self.gen_ratings = InnerProductLayer(prefix='gen_rating')
Beispiel #5
0
    def __init__(self, args, dev_id):
        super(Net, self).__init__()
        self._act = get_activation(args.model_activation)
        self.encoder = GCMCLayer(args.rating_vals,
                                 args.src_in_units,
                                 args.dst_in_units,
                                 args.gcn_agg_units,
                                 args.gcn_out_units,
                                 args.gcn_dropout,
                                 args.gcn_agg_accum,
                                 agg_act=self._act,
                                 share_user_item_param=args.share_param,
                                 device=dev_id)
        if args.mix_cpu_gpu and args.use_one_hot_fea:
            # if use_one_hot_fea, user and movie feature is None
            # W can be extremely large, with mix_cpu_gpu W should be stored in CPU
            self.encoder.partial_to(dev_id)
        else:
            self.encoder.to(dev_id)

        self.decoder = BiDecoder(in_units=args.gcn_out_units,
                                 num_classes=len(args.rating_vals),
                                 num_basis=args.gen_r_num_basis_func)
        self.decoder.to(dev_id)