def __init__(self, data, config, params, *args, **kwargs): self._random = np.random self._params_list = [ ("_factors", "factors", "factors", 10, None, None), ("_hidden_neurons", "hidden_neurons", "hidden_neurons", "(64,32)", lambda x: list(make_tuple(x)), lambda x: self._batch_remove(str(x), " []").replace(",", "-")), ("_hidden_activations", "hidden_activations", "hidden_activations", "('relu','relu')", lambda x: list(make_tuple(x)), lambda x: self._batch_remove(str(x), " []").replace(",", "-")), ("_learning_rate", "lr", "lr", 0.001, None, None), ("_l_w", "reg", "reg", 0.1, None, None) ] self.autoset_params() if self._batch_size < 1: self._batch_size = self._data.transactions self._ratings = self._data.train_dict self._sp_i_train = self._data.sp_i_train self._i_items_set = list(range(self._num_items)) self._sampler = pws.Sampler(self._data.i_train_dict) self._model = NeuralFactorizationMachineModel( self._num_users, self._num_items, self._factors, tuple( m for m in zip(self._hidden_neurons, self._hidden_activations)), self._l_w, self._learning_rate)
def __init__(self, data, config, params, *args, **kwargs): self._random = np.random self._params_list = [("_factors", "factors", "factors", 10, None, None), ("_learning_rate", "lr", "lr", 0.001, None, None), ("_l_w", "reg", "reg", 0.1, None, None)] self.autoset_params() if self._batch_size < 1: self._batch_size = self._data.transactions self._ratings = self._data.train_dict self._sp_i_train = self._data.sp_i_train self._i_items_set = list(range(self._num_items)) self._sampler = pws.Sampler(self._data.i_train_dict) self._model = FactorizationMachineModel(self._num_users, self._num_items, self._factors, self._l_w, self._learning_rate)
def __init__(self, data, config, params, *args, **kwargs): self._random = np.random self._params_list = [ ("_factors", "factors", "factors", 10, None, None), ("_learning_rate", "lr", "lr", 0.001, None, None), ("_l_w", "reg", "reg", 0.1, None, None), ("_simplify", "mf_simplification", "mf", False, None, None) ] self.autoset_params() if self._batch_size < 1: self._batch_size = self._data.transactions self._ratings = self._data.train_dict self._sp_i_train = self._data.sp_i_train self._i_items_set = list(range(self._num_items)) if ((not self._simplify) and hasattr(self._data, "nfeatures")) and (hasattr( self._data, "side_information_data")) and (hasattr( self._data.side_information_data, "feature_map")): self._nfeatures = self._data.nfeatures self._item_array = self.get_item_fragment() else: self._nfeatures = 0 self._field_dims = [self._num_users, self._num_items, self._nfeatures] self._sampler = pws.Sampler(self._data.i_train_dict, self._data.sp_i_train_ratings) self._model = FactorizationMachineModel(self._num_users, self._num_items, self._nfeatures, self._factors, self._l_w, self._learning_rate)