tfl.configs.CalibratedLinearConfig
Stay organized with collections
Save and categorize content based on your preferences.
Config for calibrated lattice model.
tfl.configs.CalibratedLinearConfig(
feature_configs=None,
regularizer_configs=None,
use_bias=True,
output_min=None,
output_max=None,
output_calibration=False,
output_calibration_num_keypoints=10,
output_initialization='quantiles',
output_calibration_input_keypoints_type='fixed'
)
Used in the notebooks
A calibrated linear model applies piecewise-linear and categorical
calibration on the input feature, followed by a linear combination and an
optional output piecewise-linear calibration. When using output calibration
or when output bounds are specified, the linear layer will be apply weighted
averaging on calibrated inputs.
Example:
model_config = tfl.configs.CalibratedLinearConfig(
feature_configs=[...],
)
feature_analysis_input_fn = create_input_fn(num_epochs=1, ...)
train_input_fn = create_input_fn(num_epochs=100, ...)
estimator = tfl.estimators.CannedClassifier(
feature_columns=feature_columns,
model_config=model_config,
feature_analysis_input_fn=feature_analysis_input_fn)
estimator.train(input_fn=train_input_fn)
Args |
feature_configs
|
A list of tfl.configs.FeatureConfig instances that
specify configurations for each feature. If a configuration is not
provided for a feature, a default configuration will be used.
|
regularizer_configs
|
A list of tfl.configs.RegularizerConfig instances
that apply global regularization.
|
use_bias
|
If a bias term should be used for the linear combination.
|
output_min
|
Lower bound constraint on the output of the model.
|
output_max
|
Upper bound constraint on the output of the model.
|
output_calibration
|
If a piecewise-linear calibration should be used on
the output of the lattice.
|
output_calibration_num_keypoints
|
Number of keypoints to use for the
output piecewise-linear calibration.
|
output_initialization
|
The initial values to setup for the output of the
model. When using output calibration, these values are used to
initialize the output keypoints of the output piecewise-linear
calibration. Otherwise the lattice parameters will be setup to form a
linear function in the range of output_initialization. It can be one of:
- String
'quantiles' : Output is initliazed to label quantiles, if
possible.
- String
'uniform' : Output is initliazed uniformly in label range.
- A list of numbers: To be used for initialization of the output
lattice or output calibrator.
|
output_calibration_input_keypoints_type
|
One of "fixed" or
"learned_interior". If "learned_interior", keypoints are initialized to
the values in pwl_calibration_input_keypoints but then allowed to vary
during training, with the exception of the first and last keypoint
location which are fixed.
|
Methods
deserialize_nested_configs
View source
@classmethod
deserialize_nested_configs(
config, custom_objects=None
)
Returns a deserialized configuration dictionary.
feature_config_by_name
View source
feature_config_by_name(
feature_name
)
Returns existing or default FeatureConfig with the given name.
from_config
View source
@classmethod
from_config(
config, custom_objects=None
)
get_config
View source
get_config()
Returns a configuration dictionary.
regularizer_config_by_name
View source
regularizer_config_by_name(
regularizer_name
)
Returns existing or default RegularizerConfig with the given name.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-08-02 UTC.
[null,null,["Last updated 2024-08-02 UTC."],[],[],null,["# tfl.configs.CalibratedLinearConfig\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/configs.py#L509-L582) |\n\nConfig for calibrated lattice model. \n\n tfl.configs.CalibratedLinearConfig(\n feature_configs=None,\n regularizer_configs=None,\n use_bias=True,\n output_min=None,\n output_max=None,\n output_calibration=False,\n output_calibration_num_keypoints=10,\n output_initialization='quantiles',\n output_calibration_input_keypoints_type='fixed'\n )\n\n### Used in the notebooks\n\n| Used in the tutorials |\n|--------------------------------------------------------------------------------------------|\n| - [TF Lattice Premade Models](https://www.tensorflow.org/lattice/tutorials/premade_models) |\n\nA calibrated linear model applies piecewise-linear and categorical\ncalibration on the input feature, followed by a linear combination and an\noptional output piecewise-linear calibration. When using output calibration\nor when output bounds are specified, the linear layer will be apply weighted\naveraging on calibrated inputs.\n\n#### Example:\n\n model_config = tfl.configs.CalibratedLinearConfig(\n feature_configs=[...],\n )\n feature_analysis_input_fn = create_input_fn(num_epochs=1, ...)\n train_input_fn = create_input_fn(num_epochs=100, ...)\n estimator = tfl.estimators.CannedClassifier(\n feature_columns=feature_columns,\n model_config=model_config,\n feature_analysis_input_fn=feature_analysis_input_fn)\n estimator.train(input_fn=train_input_fn)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `feature_configs` | A list of [`tfl.configs.FeatureConfig`](../../tfl/configs/FeatureConfig) instances that specify configurations for each feature. If a configuration is not provided for a feature, a default configuration will be used. |\n| `regularizer_configs` | A list of [`tfl.configs.RegularizerConfig`](../../tfl/configs/RegularizerConfig) instances that apply global regularization. |\n| `use_bias` | If a bias term should be used for the linear combination. |\n| `output_min` | Lower bound constraint on the output of the model. |\n| `output_max` | Upper bound constraint on the output of the model. |\n| `output_calibration` | If a piecewise-linear calibration should be used on the output of the lattice. |\n| `output_calibration_num_keypoints` | Number of keypoints to use for the output piecewise-linear calibration. |\n| `output_initialization` | The initial values to setup for the output of the model. When using output calibration, these values are used to initialize the output keypoints of the output piecewise-linear calibration. Otherwise the lattice parameters will be setup to form a linear function in the range of output_initialization. It can be one of: \u003cbr /\u003e - String `'quantiles'`: Output is initliazed to label quantiles, if possible. - String `'uniform'`: Output is initliazed uniformly in label range. - A list of numbers: To be used for initialization of the output lattice or output calibrator. |\n| `output_calibration_input_keypoints_type` | One of \"fixed\" or \"learned_interior\". If \"learned_interior\", keypoints are initialized to the values in `pwl_calibration_input_keypoints` but then allowed to vary during training, with the exception of the first and last keypoint location which are fixed. |\n\nMethods\n-------\n\n### `deserialize_nested_configs`\n\n[View source](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/configs.py#L124-L158) \n\n @classmethod\n deserialize_nested_configs(\n config, custom_objects=None\n )\n\nReturns a deserialized configuration dictionary.\n\n### `feature_config_by_name`\n\n[View source](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/configs.py#L164-L173) \n\n feature_config_by_name(\n feature_name\n )\n\nReturns existing or default FeatureConfig with the given name.\n\n### `from_config`\n\n[View source](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/configs.py#L579-L582) \n\n @classmethod\n from_config(\n config, custom_objects=None\n )\n\n### `get_config`\n\n[View source](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/configs.py#L93-L122) \n\n get_config()\n\nReturns a configuration dictionary.\n\n### `regularizer_config_by_name`\n\n[View source](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/configs.py#L179-L188) \n\n regularizer_config_by_name(\n regularizer_name\n )\n\nReturns existing or default RegularizerConfig with the given name."]]