Xtra-Computing / thundergbm

ThunderGBM: Fast GBDTs and Random Forests on GPUs
Apache License 2.0
689 stars 84 forks source link

Problem of save & load model in Linux #40

Closed TAOinfoWr closed 4 years ago

TAOinfoWr commented 4 years ago

I have some question for save & load model with thundergbm. there are two problem. 1. the problem is why some hyperparameter value is different from training when i load the model. it seem some hyperparameter value is the same as default setting. for example, i change 'depth','max_num_bin','column_sampling_rate' in training stage. but it has different value when i load the model. 2. The predict value is all zero, it seem unreasonable.

The follow is my code and os/gpu information, could someone tell me whether i have wrong operation , thanks.

------------------------------------------------------------------------

from thundergbm import TGBMClassifier from sklearn import datasets clf = TGBMClassifier(verbose=0,n_trees=20,depth=8, ... max_num_bin=200,column_sampling_rate=0.8, ... learning_rate=0.8,objective='multi:softmax') X, y = datasets.load_digits(return_X_y=True) clf.fit(X, y) TGBMClassifier(bagging=0, column_sampling_rate=0.8, depth=8, gamma=1.0, lambda_tgbm=1.0, learning_rate=0.8, max_num_bin=200, min_child_weight=1.0, n_gpus=1, n_parallel_trees=1, n_trees=20, num_class=10, objective='multi:softmax', tree_method='auto', verbose=0) model_path='/home/admin/Desktop/tgbm.model' clf.save_model(model_path) print(clf.predict(X)) [0. 1. 2. ... 8. 9. 8.] clf2 = TGBMClassifier(objective='multi:softmax') clf2.load_model(model_path) print(clf2) TGBMClassifier(bagging=0, column_sampling_rate=1.0, depth=6, gamma=1.0, lambda_tgbm=1.0, learning_rate=0.800000011920929, max_num_bin=255, min_child_weight=1.0, n_gpus=1, n_parallel_trees=1, n_trees=20, num_class=10, objective='multi:softmax', tree_method='auto', verbose=1) y_pred = clf2.predict(X) print(y_pred) [0. 0. 0. ... 0. 0. 0.]

------------------------------------------------------------------------

Ubuntu 16.04 NVIDIA driver : 440.44 CUDA Version: 10.2 GPU - GeForce RTX 2080

Kurt-Liuhf commented 4 years ago

Hi @TAOinfoWr, the problem is fixed. You can reinstall ThunderGBM and have a try. But notice that some hyper-parameters look like the default params even though they are not (e.g., tree depth). That's because when we save the model, we only save the trained GBDTs and the tree depth is already contained in the trained model. Thank you!

TAOinfoWr commented 4 years ago

it works ! thank you very much !