# Module: tfl.premade_lib

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/premade_lib.py) |

Implementation of algorithms required for premade models.

#### View aliases


**Main aliases**

[`tfl.premade.premade_lib`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib)

<br />

## Classes

[`class LayerOutputRange`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/LayerOutputRange): Enum to indicate the output range based on the input of the next layers.

## Functions

[`build_aggregation_layer(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/build_aggregation_layer): Creates an aggregation layer using the given calibrated lattice models.

[`build_calibrated_lattice_ensemble_layer(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/build_calibrated_lattice_ensemble_layer): Creates a calibration layer followed by a lattice ensemble layer.

[`build_calibration_layers(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/build_calibration_layers): Creates a calibration layer for `submodels` as list of list of features.

[`build_input_layer(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/build_input_layer): Creates a mapping from feature name to [`keras.Input`](https://www.tensorflow.org/api_docs/python/tf/keras/Input).

[`build_lattice_ensemble_layer(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/build_lattice_ensemble_layer): Creates an ensemble of [`tfl.layers.Lattice`](https://www.tensorflow.org/lattice/api_docs/python/tfl/layers/Lattice) layers.

[`build_lattice_layer(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/build_lattice_layer): Creates a [`tfl.layers.Lattice`](https://www.tensorflow.org/lattice/api_docs/python/tfl/layers/Lattice) layer.

[`build_linear_combination_layer(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/build_linear_combination_layer): Creates a [`tfl.layers.Linear`](https://www.tensorflow.org/lattice/api_docs/python/tfl/layers/Linear) layer initialized to be an average.

[`build_linear_layer(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/build_linear_layer): Creates a [`tfl.layers.Linear`](https://www.tensorflow.org/lattice/api_docs/python/tfl/layers/Linear) layer initialized to be an average.

[`build_multi_unit_calibration_layers(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/build_multi_unit_calibration_layers): Creates a mapping from feature names to calibration outputs.

[`build_output_calibration_layer(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/build_output_calibration_layer): Creates a monotonic output calibration layer with inputs range \[0, 1\].

[`build_rtl_layer(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/build_rtl_layer): Creates a [`tfl.layers.RTL`](https://www.tensorflow.org/lattice/api_docs/python/tfl/layers/RTL) layer.

[`compute_feature_keypoints(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/compute_feature_keypoints): Computes feature keypoints with the data provide in `features` dict.

[`compute_keypoints(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/compute_keypoints): Calculates keypoints for the given set of values.

[`compute_label_keypoints(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/compute_label_keypoints): Computes label keypoints with the data provide in `lables` array.

[`construct_prefitting_model_config(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/construct_prefitting_model_config): Constructs a model config for a prefitting model for crystal extraction.

[`set_categorical_monotonicities(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/set_categorical_monotonicities): Maps categorical monotonicities to indices based on specified vocab list.

[`set_crystals_lattice_ensemble(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/set_crystals_lattice_ensemble): Extracts crystals from a prefitting model and finalizes model_config.

[`set_feature_keypoints(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/set_feature_keypoints): Updates the feature configs with provided keypoints.

[`set_label_keypoints(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/set_label_keypoints): Updates the label keypoints in the `model_config`.

[`set_random_lattice_ensemble(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/set_random_lattice_ensemble): Sets random lattice ensemble in the given model_config.

[`verify_config(...)`](https://www.tensorflow.org/lattice/api_docs/python/tfl/premade_lib/verify_config): Verifies that the model_config and feature_configs are properly specified.

<br />

<br />

<br />

| ## Other Members ||
|---|---|
| AGGREGATION_LAYER_NAME | `'tfl_aggregation'` |
| CALIB_LAYER_NAME | `'tfl_calib'` |
| CALIB_PASSTHROUGH_NAME | `'tfl_calib_passthrough'` |
| INPUT_LAYER_NAME | `'tfl_input'` |
| KFL_LAYER_NAME | `'tfl_kronecker_factored_lattice'` |
| LATTICE_LAYER_NAME | `'tfl_lattice'` |
| LINEAR_LAYER_NAME | `'tfl_linear'` |
| OUTPUT_CALIB_LAYER_NAME | `'tfl_output_calib'` |
| OUTPUT_LINEAR_COMBINATION_LAYER_NAME | `'tfl_output_linear_combination'` |
| RTL_INPUT_NAME | `'tfl_rtl_input'` |
| RTL_LAYER_NAME | `'tfl_rtl'` |
| absolute_import | Instance of `__future__._Feature` |
| division | Instance of `__future__._Feature` |
| print_function | Instance of `__future__._Feature` |

<br />