tf.keras.constraints.RadialConstraint
Stay organized with collections
Save and categorize content based on your preferences.
Constrains Conv2D
kernel weights to be the same for each radius.
Inherits From: Constraint
Also available via the shortcut function
tf.keras.constraints.radial_constraint
.
For example, the desired output for the following 4-by-4 kernel:
kernel = [[v_00, v_01, v_02, v_03],
[v_10, v_11, v_12, v_13],
[v_20, v_21, v_22, v_23],
[v_30, v_31, v_32, v_33]]
is this::
kernel = [[v_11, v_11, v_11, v_11],
[v_11, v_33, v_33, v_11],
[v_11, v_33, v_33, v_11],
[v_11, v_11, v_11, v_11]]
This constraint can be applied to any Conv2D
layer version, including
Conv2DTranspose
and SeparableConv2D
, and with either "channels_last"
or "channels_first"
data format. The method assumes the weight tensor is
of shape (rows, cols, input_depth, output_depth)
.
Methods
from_config
View source
@classmethod
from_config(
config
)
Instantiates a weight constraint from a configuration dictionary.
Example:
constraint = UnitNorm()
config = constraint.get_config()
constraint = UnitNorm.from_config(config)
Args |
config
|
A Python dictionary, the output of get_config .
|
get_config
View source
get_config()
Returns a Python dict of the object config.
A constraint config is a Python dictionary (JSON-serializable) that can
be used to reinstantiate the same object.
Returns |
Python dict containing the configuration of the constraint object.
|
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. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[],[],null,["# tf.keras.constraints.RadialConstraint\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v2.13.1/keras/constraints.py#L254-L341) |\n\nConstrains `Conv2D` kernel weights to be the same for each radius.\n\nInherits From: [`Constraint`](../../../tf/keras/constraints/Constraint)\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tf.keras.constraints.radial_constraint`](https://www.tensorflow.org/api_docs/python/tf/keras/constraints/RadialConstraint)\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n\\`tf.compat.v1.keras.constraints.RadialConstraint\\`, \\`tf.compat.v1.keras.constraints.radial_constraint\\`\n\n\u003cbr /\u003e\n\nAlso available via the shortcut function\n[`tf.keras.constraints.radial_constraint`](../../../tf/keras/constraints/RadialConstraint).\n\nFor example, the desired output for the following 4-by-4 kernel: \n\n kernel = [[v_00, v_01, v_02, v_03],\n [v_10, v_11, v_12, v_13],\n [v_20, v_21, v_22, v_23],\n [v_30, v_31, v_32, v_33]]\n\nis this:: \n\n kernel = [[v_11, v_11, v_11, v_11],\n [v_11, v_33, v_33, v_11],\n [v_11, v_33, v_33, v_11],\n [v_11, v_11, v_11, v_11]]\n\nThis constraint can be applied to any `Conv2D` layer version, including\n`Conv2DTranspose` and `SeparableConv2D`, and with either `\"channels_last\"`\nor `\"channels_first\"` data format. The method assumes the weight tensor is\nof shape `(rows, cols, input_depth, output_depth)`.\n\nMethods\n-------\n\n### `from_config`\n\n[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/constraints.py#L83-L101) \n\n @classmethod\n from_config(\n config\n )\n\nInstantiates a weight constraint from a configuration dictionary.\n\n#### Example:\n\n constraint = UnitNorm()\n config = constraint.get_config()\n constraint = UnitNorm.from_config(config)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------|--------------------------------------------------|\n| `config` | A Python dictionary, the output of `get_config`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| A [`tf.keras.constraints.Constraint`](../../../tf/keras/constraints/Constraint) instance. ||\n\n\u003cbr /\u003e\n\n### `get_config`\n\n[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/constraints.py#L72-L81) \n\n get_config()\n\nReturns a Python dict of the object config.\n\nA constraint config is a Python dictionary (JSON-serializable) that can\nbe used to reinstantiate the same object.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| Python dict containing the configuration of the constraint object. ||\n\n\u003cbr /\u003e"]]