I hereby claim:
- I am benoitdescamps on github.
- I am bendesc (https://keybase.io/bendesc) on keybase.
- I have a public key ASCc_8P9Faka2-t-le6Gl-HtTVsKBjTMR_207ktVS57SOwo
To claim this, I am signing this object:
def get_cost(target,Q,action_indices): | |
""" | |
Cost-function of the Q-matrix attempting to approximate the reward-function | |
:param tf.placeholder target: placeholder for the values of the registered rewards | |
:param tf.placeholder Q: output of the Q-matrix the registered state | |
:param tf.placeholder action_indices: placeholder for the indices of the registered actions | |
:return: tf.tensor mean_squared error the reward vs Q-matrix | |
""" | |
row_indices = tf.range(tf.shape(action_indices)[0]) | |
full_indices = tf.stack([row_indices, action_indices], axis=1) |
def define_Q(input_shape=(16,16)): | |
""" | |
Defines the Q-matrix and returns the input and output tensorflow tensors. | |
Args: | |
:param Tuple input_shape: | |
:return: Tuple[tf.tensor, tf.tensor] | |
""" | |
input = tf.placeholder(shape=(None,)+input_shape+(1,), dtype=tf.float32) | |
nn_1 = tf.layers.batch_normalization(input) |
I hereby claim:
To claim this, I am signing this object:
import breeze.stats.distributions.{Gamma,Uniform,Poisson} | |
import com.microsoft.ml.spark.LightGBMClassifier | |
import tuning.RandomGridBuilder | |
object example_lgbm{ | |
def main(args: Array[String]): Unit = { | |
val lgbm = new LightGBMClassifier() | |
val randomGrid = new RandomGridBuilder(5) | |
.addDistr(lgbm.learningRate,Gamma(1.0,0.1)) |
class RandomGridBuilder(n: Int) { | |
private val paramDistr = mutable.Map.empty[Param[_],Any] | |
def addDistr[T](param: Param[T], distr: Any ): this.type = distr match { | |
case _ : Rand[_] => {paramDistr.put(param, distr) | |
this} | |
case _ : Array[_] => { paramDistr.put(param, distr) | |
this} | |
case _ => throw new NotImplementedError("Distribution should be of type breeze.stats.distributions.Rand or an Array") |
val lr = new LogisticRegression().setMaxIter(10) | |
val randomGrid = new RandomGridBuilder(10) | |
.addDistr(lr.regParam,Gamma(0.5,0.1)) | |
.addDistr(lr.elasticNetParam,Gamma(0.5,0.1)) | |
.addDistr(lr.threshold,Gaussian(0.5,0.05)) | |
.addDistr(lr.standardization,Array(true,false)) | |
.build() |
import org.apache.spark.ml.Pipeline | |
import org.apache.spark.ml.tuning.CrossValidatorModel | |
import org.apache.spark.ml.param.ParamMap | |
val pipeline: Pipeline = ... | |
val paramGrid: Array[ParamMap] = new ParamGridBuilder(). | |
addGrid(...). | |
addGrid(...). | |
build |
class SuccessiveHalving(object): | |
"""Applies successhalving on a model for n configurations max r ressources. | |
Args: | |
estimator: object instance with subclass SHBaseEstimator: | |
estimator wrapper | |
n: integer: | |
number of hyperparameter configurations to explore | |
r: integer: |
class SHSklearnEstimator(SHBaseEstimator): | |
def __init__(self,model,ressource_name=None): | |
self.model = model | |
self.ressource_name = ressource_name | |
self.env = None | |
def update(self,Xtrain,ytrain,Xval,yval,scoring,n_iterations): | |
self.set_params(**{'warm_start':True,self.ressource_name:n_iterations}) | |
self.model.fit(Xtrain,ytrain) |
class SHSklearnEstimator(SHBaseEstimator): | |
def __init__(self,model,ressource_name=None): | |
self.model = model | |
self.ressource_name = ressource_name | |
self.env = None | |
def update(self,Xtrain,ytrain,Xval,yval,scoring,n_iterations): | |
self.set_params(**{'warm_start':True,self.ressource_name:n_iterations}) | |
self.model.fit(Xtrain,ytrain) |