src/rime/models/lda.py
def fit(self, D):
        """ learn from training_data on gpu w/ mini-batches; clear gpu in the end """

        user_index = D.user_df[D.user_df['_hist_len'] > 0].index  # prune empty users
        i, j = create_matrix(D.event_df, user_index, self._item_list, 'ij')
        G = dgl.heterograph(
            {('doc', '', 'word'): (i, j)},
            {'doc': len(user_index), 'word': len(self._item_list)},
        )

        lit = _LitLDA(self.model, G)
        trainer = Trainer(
            max_epochs=self.max_epochs, gpus=int(torch.cuda.is_available()),
            limit_val_batches=2, callbacks=[lit._checkpoint],
        )
        print(trainer.log_dir)

        train_set, valid_set = default_random_split(np.arange(G.num_nodes('doc')))
        trainer.fit(
            lit,
            DataLoader(train_set, self.batch_size, shuffle=True),
            DataLoader(valid_set, self.batch_size),
        )
        lit._load_best_checkpoint("best")
        lit._update_model_from_buffer_change_device()

        return self
 learn from training_data on gpu w/ mini-batches; clear gpu in the end 
learn from training_data on gpu w/ mini-batches; clear gpu in the end
learn from training_data on gpu w / mini - batches ; clear gpu in the end
def fit(self, D):
        user_index = D.user_df[D.user_df['_hist_len'] > 0].index  
        i, j = create_matrix(D.event_df, user_index, self._item_list, 'ij')
        G = dgl.heterograph(
            {('doc', '', 'word'): (i, j)},
            {'doc': len(user_index), 'word': len(self._item_list)},
        )
        lit = _LitLDA(self.model, G)
        trainer = Trainer(
            max_epochs=self.max_epochs, gpus=int(torch.cuda.is_available()),
            limit_val_batches=2, callbacks=[lit._checkpoint],
        )
        print(trainer.log_dir)
        train_set, valid_set = default_random_split(np.arange(G.num_nodes('doc')))
        trainer.fit(
            lit,
            DataLoader(train_set, self.batch_size, shuffle=True),
            DataLoader(valid_set, self.batch_size),
        )
        lit._load_best_checkpoint("best")
        lit._update_model_from_buffer_change_device()
        return self
def fit ( self , D ) : user_index = D . user_df [ D . user_df [ '_hist_len' ] > 0 ] . index i , j = create_matrix ( D . event_df , user_index , self . _item_list , 'ij' ) G = dgl . heterograph ( { ( 'doc' , '' , 'word' ) : ( i , j ) } , { 'doc' : len ( user_index ) , 'word' : len ( self . _item_list ) } , ) lit = _LitLDA ( self . model , G ) trainer = Trainer ( max_epochs = self . max_epochs , gpus = int ( torch . cuda . is_available ( ) ) , limit_val_batches = 2 , callbacks = [ lit . _checkpoint ] , ) print ( trainer . log_dir ) train_set , valid_set = default_random_split ( np . arange ( G . num_nodes ( 'doc' ) ) ) trainer . fit ( lit , DataLoader ( train_set , self . batch_size , shuffle = True ) , DataLoader ( valid_set , self . batch_size ) , ) lit . _load_best_checkpoint ( "best" ) lit . _update_model_from_buffer_change_device ( ) return self
learn from training_data on gpu w/ mini-batches; clear gpu in the end
learn from training_data on gpu w / mini - batches ; clear gpu in the end
""" learn from training_data on gpu w/ mini-batches; clear gpu in the end """ # prune empty users
self
D