tensorflow / lattice

Lattice methods in TensorFlow
Apache License 2.0
518 stars 94 forks source link

Example to train a lattice model with monotonic constraints #38

Closed PoorvaRane closed 4 years ago

PoorvaRane commented 4 years ago

Hi! Could you please share an example to train a lattice with monotonic constraints? I tried using projection ops but am facing an error while saving and restoring the model from the checkpoint (similar to Issue https://github.com/tensorflow/lattice/issues/35)

mmilanifard commented 4 years ago

I assume you are using an estimator API. This is an example: https://github.com/tensorflow/lattice/blob/master/examples/coffee_test.py Please share further details about the error you are getting, including your TF, TFL and python version.

On another note, I suggest you wait for the new library to be released, which uses Keras layers and handles constraints automatically. I expect that to happen in 3-4 weeks.

PoorvaRane commented 4 years ago

Thanks @mmilanifard ! I am using the estimator API and tfl.calibration_layer() and tfl.lattice_layer() for the calibrations and lattice. I am also using tf.estimator.train_and_evaluate with tf.estimator.TrainSpec() and tf.estimator.EvalSpec() to train and evaluate my model. I suspect there may also be something to do with the tf.estimator.train_and_evaluate function too.

My TF, TFL and python versions are:

python                           2.7.10
tensorflow                       1.14.0  
tensorflow-lattice               0.9.9 

Alright! I can wait for the new version to be released as well. Thanks!

mmilanifard commented 4 years ago

Sorry for the long delays on this. RFC is out and we are hoping for a release by mid Jan. PR: https://github.com/tensorflow/community/pull/186 RFC doc