autonomio / talos

Hyperparameter Experiments with TensorFlow and Keras
https://autonom.io
MIT License
1.63k stars 268 forks source link

Randomizer() i.e. next level random search #84

Closed mikkokotila closed 5 years ago

mikkokotila commented 6 years ago

It looks like possibly the lowest hanging fruit in terms of providing the user with options for the optimization strategy, and improving the results that come from uniform standards, have to do with quasirandom (low discrepancy) sequences.

The issue with uniform random function i.e. pseudorandom function is "clumping" where luck plays an important role. The goal of the quasirandom approaches (e.g. Latin Hypercube, Sobol, Halton...) is to minimize clumping.

One of the more interesting variations here seems to be Latin hypercube with a sudoku-like constraint. [link]

Basically what we seem to need here is a way to perform a quasirandom shuffle (instead of the pseudorandom one we use now). That library is not available it seems, so it might have to be built. My goal would be to make available for the user several quasirandom shuffle options.

mikkokotila commented 6 years ago

Just to update, as this is taking more work than I thought. This is slightly expanded from the initial scope also. I think we have to consider three kinds of randomness:

Given the emphasis we have on random search, I believe it's important to have strong coverage for all three. The differences in terms of output are notable:

So far I've implemented:

r = Randomizer(self.param_log)

r.sobol() # sobol sequence
r.uniform_crypto() # from secrets
r.uniform_mersenne() # from random
r.latin_matrix() # latin hypercube
r.latin_improved() # improved latin hypercube
r.latin_sudoku() # latin hypercube with sudoku type constraint
r.korobov_matrix() # korobov design matrix
r.halton() # halton sequence
r.quantum() # this is actual quantum mechanics true randomness! :) 

Based on everything I've studied and see so far, it seems fair to say that not all randomness is created equal. As we get these into use, it will be very interesting to see how things materialize from dataset to dataset. Not all are covered in any literature, and those that are, with very limited datasets.

ruojol commented 6 years ago

Is this allready available in dev branch?

mikkokotila commented 6 years ago

You can get it in daily-dev for now. Most likely will merge with dev this week. The PR is already there, but the tests (basically pep8) suggest that I better clean the code before merging.

mikkokotila commented 6 years ago

Note that Latin improved takes a very long time to, so I'm going to remove that.

C0NTRIBUTE commented 6 years ago

It would be nice to be able to input a random function (that takes in a 1-d array of integers obviously) through the random_method argument in scan. That way if the user is already working with random numbers with something like mlk_random, they can just use whatever method they like.

mikkokotila commented 5 years ago

This was done some time ago, so closing.