bstellato / mlopt

The Machine Learning Optimizer
Apache License 2.0
101 stars 24 forks source link

Develop learner multilabel #2

Open bstellato opened 5 years ago

bstellato commented 5 years ago

Add option to have multiple labels in the PyTorch learner. This is helpful when the strategy for the integer variables corresponds to the actual integer variables vector. (Similar holds for active constraints).

This PR also adds the n_layers as parameter.

TODO

juliayyan commented 5 years ago

So I was running this and got a runtime warning:

RuntimeWarning: overflow encountered in exp
  normalized_outputs = np.reciprocal(1 + np.exp(-outputs))  # Normalize using sigmoid

It's still running so I can't confirm, but I think the issue might be here: https://github.com/bstellato/mlopt/blob/develop_learner_multilabel/mlopt/learners/pytorch/pytorch.py#L92 https://github.com/bstellato/mlopt/blob/develop_learner_multilabel/mlopt/learners/pytorch/pytorch.py#L104

Unlike the one-hot case, I need to wrap the sigmoid around the net outputs to get 0-1s: https://github.com/bstellato/mlopt/blob/develop_learner_multilabel/mlopt/learners/pytorch/pytorch.py#L299 which is not being done before the calls to the MSE function.

bstellato commented 5 years ago

I think it is just a warning. A solution could be this little trick which needs to be adapted to the vectorized case. Another solution is to silence that working inside the function call. In any case it should not affect the output of your code.