LaunchpadAI / space-bandits

GNU General Public License v3.0
102 stars 30 forks source link

Thompson Sampling Too Slow!!! #6

Open AlliedToasters opened 5 years ago

AlliedToasters commented 5 years ago

The Thompson sampling implementation is slow! This is due to the random normal number generation process; with many features (or many nodes in the last layer of a neural model), sample vectors need to be generated from a distribution with a covariance matrix of size NxN, so the compute required scales quadratically with the number of linear features or nodes in the last neural network layer.

Temporary Work-Around If you have many features, use a neural_linear model instead of linear and use a small final layer (I typically use 12 or less nodes).

Current Solution Currently space-bandits uses multiprocessing to speed up this bottleneck.

Better Solution PyTorch may provide a kernel for this sort of sampling that's more efficient than the multiprocessing hack I have used here. This would add PyTorch as a dependency but that's where I'd like to go anyway.

lgabs commented 5 years ago

First, I'd like to congratulate you for such a nice algorithm, I've been rading it about these days and the results found in mentioned paper look nice, as well as the contextualization for many problems. In my case, I've trained and tested a 100k dataset here and it kind of worked (low accuracy/recall), but as you've mentioned in your demos notebooks, it is indeed a more difficul task. My question is: is there any special care about saving results? When I try to use the save() method, my machine breaks. I've used the pre-defined hyperparameters for the Neuro Linear. Thanks!