Closed ma14ch closed 4 months ago
Thanks, man! The problem is related to TensorFlow. Tensorflow 2.16 starts using Keras 3.0, so tf1 syntax is no longer supported and is used in this library. See https://github.com/massquantity/LibRecommender?tab=readme-ov-file#basic-dependencies-for-libreco
⠀⠄⣀⣄⡤⣤⡴⣤⣤⣤⣤⣀⣀⠀⠀⡀⢀⠈⠈⠙⠮⡽⢭⡻⣝⡻⣏⠿⡭⢯⠝⡊⠉⡀⠀⠀⠀⠀⢀⣀⣤⣄⣦⡴⣤⣤⣄⣀⡀⠀ ⡾⣽⣳⢯⣟⣷⣻⡽⣯⣟⣿⣻⢿⣿⣶⣤⣄⠀⢀⠊⡀⠈⠃⠻⣜⢳⡭⡛⠑⠃⠀⠀⠀⢀⢂⣥⣶⣿⢿⣿⣻⢯⡿⣽⣳⢟⡾⣽⣻⣟ ⣟⡷⣯⣟⡾⣧⣟⣷⣻⡼⣾⢽⣻⢾⣝⣿⣻⣿⣶⣤⣀⠠⠄⠁⠈⢁⠂⠁⡀⠄⣈⣰⣼⣾⣿⣟⡿⣞⡿⣼⢯⡿⣵⢯⣯⢿⣽⣳⢟⡾ ⣯⢿⡵⣯⢷⡻⣜⠶⣭⢳⣭⢻⡜⣯⢟⣾⣷⣯⣟⡿⣿⣷⣦⡔⠂⢀⠐⢠⣱⣾⡿⣟⡿⣽⣾⡽⢾⡹⣝⢧⡻⡼⣭⠳⣏⡟⡾⣭⢿⡽ ⣯⡟⡽⣎⢷⡹⢎⡷⢎⣳⢬⢧⣛⡴⣫⢶⡹⣞⡽⣻⣷⣽⣻⢿⣿⣶⣾⣿⣟⣯⣿⣽⡟⣯⢳⡝⣣⡝⢮⣓⠷⣳⢎⡟⡶⢭⡳⣭⢏⡿ ⢷⡹⣳⡝⣮⢝⡫⢜⠫⠘⠌⠂⠁⠊⡑⠪⠱⢎⡵⢫⡞⣽⢻⣿⣾⣽⣻⣾⢿⣻⣙⢶⡹⢎⠳⠉⠓⠈⠁⠈⢉⠁⠋⢞⡹⢣⡟⣜⣫⢼ ⢧⣛⡵⣚⠕⠊⠐⠀⠀⠀⠀⠀⢀⣁⢀⠀⢀⠀⡈⠡⠙⣜⢣⠻⡼⢿⢿⡹⢧⣳⡽⠂⢁⠀⡀⢀⢁⣁⠠⢀⠀⡀⠄⠀⠀⠃⠙⡞⣬⢳ ⡻⡜⠶⠉⠀⠈⠁⠄⣠⣼⣶⣿⣿⡿⣿⣿⣿⣶⣦⣔⡂⠠⠌⠋⠵⣫⢎⠽⠋⠁⣀⢨⣴⣶⣿⢿⡿⣿⣿⣿⣶⣦⣤⡁⢀⠈⠀⠈⢱⢫ ⡳⠍⠀⠀⠀⢈⣴⣿⣿⣟⣯⢷⣯⣿⣷⣟⣮⣿⣽⢿⣿⣷⣦⣁⠂⡀⠂⢠⣱⣶⣿⢿⣻⣽⣞⣿⣿⣷⣟⡾⣿⡽⣿⣿⣦⣀⠀⠁⠀⠑ ⠓⠀⠄⠠⢡⣾⣿⢯⡷⣾⣽⡿⣟⢯⡻⣭⢻⣜⡻⢿⡾⣷⣟⣿⣿⣶⣽⣿⣿⣽⣾⢿⡻⡝⢯⡞⣵⢫⡟⣿⣷⣟⡷⣯⢿⣿⣦⠐⢀⠀ ⠁⠈⠀⢰⣿⡿⣯⣟⣾⡿⣏⢷⡹⣎⠷⣭⢳⠮⣝⣣⢯⣝⡻⢿⣿⣯⣿⣿⠻⣝⢮⣓⠷⣹⠳⣞⡵⣫⢾⡱⢯⢿⣿⣽⡿⣽⣿⣆⠀⠀ ⠀⠠⠀⣿⣿⣽⣳⣾⣟⡳⡝⣎⢷⣩⣛⡴⠫⠙⠌⠓⠺⠜⣭⢳⢮⣝⡳⢎⣿⣘⡧⠋⠞⠱⠛⠼⣧⣛⡼⡹⣏⠾⣹⣿⣟⣷⣻⣿⡄⠀ ⠀⠀⠰⣿⣳⢯⣷⣿⢭⡳⣝⡺⡜⣶⠋⢁⠐⠈⢀⠐⡀⢈⠠⠙⠶⣮⣽⠛⠉⠁⡀⠐⠀⠀⠤⠀⠈⠹⣞⡵⢭⣫⢗⡽⣿⣞⣷⣻⡖⠀ ⠀⠀⠱⣿⡽⣯⣿⡟⢮⡵⢣⣟⠼⠁⢀⠂⣤⣼⣾⣿⣿⣿⣶⣦⣄⡀⢠⣰⣾⣿⣿⣿⣿⣶⣆⡀⠆⠀⡙⢾⣣⠗⣯⢞⣿⣻⢶⣻⡕⠀ ⠀⠀⢩⢿⡽⣞⣿⡝⣧⡝⣳⢞⠁⠀⠄⣼⣿⡿⣽⣞⣳⣟⣾⣽⣿⣿⣿⣿⣟⣾⣳⣟⡾⣽⣿⣷⡀⠂⠄⢚⡧⣻⡜⣯⢾⣯⣟⡷⡍⠀ ⠀⢀⠂⣿⡽⣯⢿⣛⠶⣭⢳⣞⠀⠀⢐⣿⣿⣽⣳⣿⡟⣯⢻⡽⣻⣿⢿⡻⣏⢿⡹⣿⣿⣳⣯⣿⡧⠐⠀⢢⡝⣶⡹⣎⣿⣞⣷⣻⠄⠀ ⣃⠀⠂⢸⣿⣯⣟⣯⢟⡶⡹⢾⡄⠀⠌⣿⣷⢯⣿⡷⣹⢎⠷⡩⢓⢮⠳⡝⣎⠷⣹⢳⣿⡷⣯⣿⡧⠃⠠⢱⡹⢶⡹⣞⣿⡽⣞⡧⠐⠀ ⢧⡈⠄⡈⢿⣷⢯⣿⣯⢖⣯⢻⣧⠀⠈⣿⣿⢯⣿⣷⢫⢾⡁⢀⠈⠀⠁⠀⠌⣹⡱⣏⣿⣟⡷⣿⠏⡀⠡⢧⡛⣧⢻⣽⣿⣽⡻⠄⠁⠀ ⡳⣥⠀⠠⠙⣿⣯⢿⣿⡞⣜⣣⢿⡆⢀⠸⣿⣟⣾⣯⡟⣾⣧⠀⠀⠀⡀⠌⣰⡷⣹⣽⡿⣽⣿⡿⠀⢄⣾⢧⢻⡼⣻⣿⢷⣯⠛⠀⠀⢴ ⡝⡶⢣⠀⡁⠸⣿⣟⣾⣿⣧⢳⣎⡽⡄⠠⠹⣿⣾⡽⣿⣎⢿⣧⣀⠀⢄⣶⢿⣱⣿⣿⡽⣷⡿⢀⠀⣼⣏⢾⡯⣿⣿⣯⣿⡟⠀⢁⡘⢮ ⣯⡝⣯⢳⡀⠀⠙⣿⣯⣿⣷⡯⣽⡞⣽⣆⠠⠘⢿⣿⡽⣿⣷⣻⢬⡻⣜⢮⣳⣿⣿⣳⣿⠏⠀⢄⣾⠟⣼⢻⣼⣿⢯⣿⠟⢀⠠⣠⢏⡷ ⣷⡽⣎⢯⢷⣄⠀⠜⢻⣯⣿⢿⣧⣟⠶⣹⢷⡀⡈⠽⢿⣷⣯⢿⣷⣻⣼⣿⣿⣿⣿⠟⡁⢀⣴⡿⣭⢻⣼⣿⡿⣯⣿⠏⡐⠠⣐⡳⢮⣽ ⣷⣻⣮⢏⡾⣹⣦⠀⠀⢻⣿⣟⡿⣯⣟⡱⣞⣻⣆⠀⢈⠻⢿⣿⣻⣿⣟⣿⣾⠟⠁⠀⣤⣿⢻⡜⣧⣿⡿⣯⣿⡿⠃⡀⢠⢳⡭⣝⣳⢾ ⡷⣯⣟⣿⣞⡵⣫⢷⡀⠀⠉⣿⣿⡽⣿⣷⣣⢷⣹⢻⣦⡀⠈⠙⠻⣿⠿⠋⠁⠀⣼⠿⣝⠶⣫⣾⣿⡿⣽⣿⠛⠀⠀⣤⢛⡶⣹⢾⡽⣯ ⣟⡷⣾⣽⣻⣷⣣⢏⡿⣆⡁⠀⠹⢿⣷⣻⣿⣮⣳⢏⡶⢻⣳⣄⠀⡀⠀⣀⡾⣝⣣⠟⣼⣳⣿⣟⣷⣿⠟⠡⢈⢠⡿⣴⢫⢾⣽⣫⢷⣯ ⣯⣟⡾⣵⢯⣿⣿⣮⡽⣏⢷⣤⠐⠈⠻⢿⣾⣟⣿⣾⣵⢫⢶⡹⣟⢤⡳⣏⠿⡼⣥⣿⣷⢿⣽⣾⠟⠁⠂⣠⡶⡟⣧⢏⣿⡿⣶⢯⣟⡾ ⡷⣯⡽⢯⣟⡾⣽⢿⣿⣯⢞⡭⢿⣄⠁⠈⠹⢿⣾⣳⢿⣿⣧⣻⢬⣳⢣⣭⢻⣵⣿⣟⣾⣿⠟⠁⠀⢂⣵⢿⡹⣝⣾⣿⢿⣽⣳⣟⡾⣽ ⣟⣷⢻⣟⡾⣽⢯⣞⣯⢿⣿⣺⢵⣚⡷⣤⠁⠀⠙⠿⣿⣞⡿⣿⣧⣷⣫⣾⣿⣻⣷⡿⠛⠁⠀⣁⣼⢿⡹⣎⣷⣿⡿⣽⢯⣶⣻⢞⣽⣳ ⠙⢾⣻⢾⣽⣳⣟⡾⣽⢯⣟⣿⣷⣏⢾⡹⣻⣄⡀⠀⠉⠿⣿⣷⣯⢷⣟⣷⣿⡟⠋⡐⠀⢢⣵⠿⣩⡞⣵⣿⣿⢯⣟⣭⣟⡾⣽⣛⣮⣟ ⠀⠈⠹⣻⣶⣻⠾⣽⣏⡿⣮⢷⣻⢿⣷⣽⢲⡝⡷⢧⣀⠀⠀⠙⠿⣿⡿⢋⡁⠠⢁⣰⢾⢯⡝⣞⣳⣿⣿⣻⡽⡾⣽⠾⣭⣟⣷⡻⠞⠀ ⠀⠈⢀⠀⠻⣿⣟⣧⣟⡷⣯⢿⣭⢿⣽⣻⣿⣾⡹⣏⡽⣳⣤⡀⠀⠀⠄⢂⢤⣵⣟⡻⣎⣷⣽⣿⢿⡽⣞⣷⣻⣽⣳⣟⣷⣿⠾⠁⠀⠁ ⣏⢦⠀⠈⠀⠈⢻⣿⣾⣽⣳⡟⣾⣛⣮⢷⡯⣟⣿⣾⣵⢫⡝⡿⣶⣤⣴⡻⣏⠷⣎⣷⣿⣟⣯⣿⣾⣽⣿⣶⣿⣶⣿⣾⣿⣥⣦⣤⣤⣴ ⡽⢎⡷⣂⠠⠐⠂⠈⠻⣾⣷⣻⣳⣟⡾⣯⣽⣻⢾⡽⣿⢿⣼⣳⡝⣮⢳⡝⣮⣿⣿⣟⡷⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⣟⣿⣿⣿⣻ ⣽⣫⠼⣭⡓⢦⣁⣀⠄⢈⠻⢿⡷⣯⢷⣛⣾⣳⢯⣟⡾⢯⣟⣷⣿⣮⣷⣿⣿⡻⣧⢿⣽⣳⣿⣿⣽⣟⣿⣾⣿⣵⣿⣧⣟⣾⣿⣣⣿⣺
MemoryError Traceback (most recent call last) Cell In[12], line 2 1 model_LGCN=LightGCN("ranking", data_info, loss_type='bpr', embed_size=2, n_epochs=20, lr=0.001, lr_decay=False, epsilon=1e-08, amsgrad=False, reg=None, batch_size=256, num_neg=1, dropout_rate=0.0, n_layers=2, margin=1.0, sampler='random', seed=42, device=device, lower_upper_bound=None, with_training=True) ----> 2 model_LGCN.fit(train_data, neg_sampling=True, verbose=2, shuffle=True, eval_data=None, metrics=None, k=10, eval_batch_size=1, eval_user_num=None, num_workers=0)
File ~/anaconda3/envs/cornac/lib/python3.11/site-packages/libreco/bases/embed_base.py:133, in EmbedBase.fit(self, train_data, neg_sampling, verbose, shuffle, eval_data, metrics, k, eval_batch_size, eval_user_num, num_workers) 131 self.show_start_time() 132 if not self.model_built: --> 133 self.build_model() 134 self.model_built = True 135 if self.trainer is None:
File ~/anaconda3/envs/cornac/lib/python3.11/site-packages/libreco/algorithms/lightgcn.py:118, in LightGCN.build_model(self) 116 def build_model(self): 117 set_torch_seed(self.seed) --> 118 self.torch_model = LightGCNModel( 119 self.n_users, 120 self.n_items, 121 self.embed_size, 122 self.n_layers, 123 self.dropout_rate, 124 self.user_consumed, 125 self.device, 126 ) ... 1265 return out 1266 else: -> 1267 return np.zeros(self.shape, dtype=self.dtype, order=order)
MemoryError: Unable to allocate 30.2 GiB for an array with shape (33789, 240132) and data type float32
This is a memory issue. The LightGCN model tried to allocate 30.2 GiB memory but failed. You can remove some users that are not active in the original data.
Tnx a lot , I did a memory upgrade :)
Dear massquantity Thanks a lot for your Open source project development ,It's sooooooo helpful to my master's thesis :) I love you this is the problem :
{ "name": "AttributeError", "message": "
batch_normalization
is not available with Keras 3.", "stack": "--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[6], line 4 1 from libreco.algorithms import FM 2 model_FM=FM('ranking', data_info, loss_type='cross_entropy', embed_size=16, n_epochs=5, lr=0.001, lr_decay=False, epsilon=1e-05, reg=None, batch_size=256, sampler='random', num_neg=1, use_bn=True, dropout_rate=None, multi_sparse_combiner='sqrtn', seed=42, lower_upper_bound=None, tf_sess_config=None) ----> 4 model_FM.fit(train_data, neg_sampling=True, verbose=1, shuffle=True, eval_data=None, metrics=None, k=10, eval_batch_size=256, eval_user_num=None, num_workers=0)File ~/anaconda3/envs/cornac/lib/python3.11/site-packages/libreco/bases/tf_base.py:128, in TfBase.fit(self, train_data, neg_sampling, verbose, shuffle, eval_data, metrics, k, eval_batch_size, eval_user_num, num_workers) 126 self.show_start_time() 127 if not self.model_built: --> 128 self.build_model() 129 self.model_built = True 130 if self.trainer is None:
File ~/anaconda3/envs/cornac/lib/python3.11/site-packages/libreco/algorithms/fm.py:166, in FM.build_model(self) 163 # For original FM, just add K dim together: 164 # pairwise_term = 0.5 * tf.reduce_sum(pairwise_term, axis=1) 165 if self.use_bn: --> 166 pairwise_term = tf.layers.batch_normalization( 167 pairwise_term, training=self.is_training 168 ) 169 pairwise_term = tf_dense(units=1, activation=tf.nn.elu)(pairwise_term) 170 self.output = tf.squeeze(tf.add(linear_term, pairwise_term))
File ~/anaconda3/envs/cornac/lib/python3.11/site-packages/tensorflow/python/util/lazy_loader.py:207, in KerasLazyLoader.getattr(self, item) 200 raise AttributeError( 201 \"
tf.compat.v2.keras
is not available with Keras 3. Just use \" 202 \"import keras
instead.\" 203 ) 204 elif self._tfll_submodule and self._tfll_submodule.startswith( 205 \"internal.legacy.\" 206 ): --> 207 raise AttributeError( 208 f\"{item}
is not available with Keras 3.\" 209 ) 210 module = self._load() 211 return getattr(module, item)AttributeError:
batch_normalization
is not available with Keras 3." }