Ask Your Question

learning model size

asked 2015-02-24 15:17:39 -0500

Geronimo gravatar image

I'm using opencv's CvBoost to classify. I've trained the classifier with several gigabytes of data and then I save it off. The model has a tree of 1000 weak learners with a depth of 20 (the default settings). Now I want to load it up to predict classes in real time production code. However, the size of the learning model is HUGE (nearly a gigabyte). I believe this is because the save function saves off all of the data used for learning so the training model can be properly updated. However, I don't need this functionality at run-time, I just want to use the fixed parameters (1000 weak learners, etc) which shouldn't be much data.

Is there a way to save off and load just the weak learner parameters into CvBoost?

Does anyone have experience reducing the learning model data size with this or another opencv learning model? Note: CvBoost inherits from CvStatModel which has the save/load functions.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2015-03-05 17:40:22 -0500

Geronimo gravatar image

I realized that with 1000 learners and a depth of 20, that's potentially 2^20*1000 learning parameters, i.e. about a billion or 1 gigabyte. So turns out that the learning model needs all of that space to store all of the trees.

To reduce the size I must lower the tree depth and/or number of learners. For example, reducing tree depth to 5 used only 21 mb (though it seemed to take around the same amount of time to build the learning model). Perhaps decreasing the weight trim rate would result in more trees that are pruned before reaching depth 20 (and thus reduce memory size as well). I haven't tested this yet.

Case closed.

edit flag offensive delete link more


Didnt really noticed this topic, but indeed, tree based models grow exponentially if you increase their depth since each leaf expands in two new leaves. Reducing the number of depth layers indeed helps alot in reducing the size!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-06 02:08:25 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-02-24 15:17:39 -0500

Seen: 161 times

Last updated: Mar 05 '15