tf.keras.constraints.NonNeg
Stay organized with collections Save and categorize content based on your preferences.
Constrains the weights to be non-negative.
Inherits From: Constraint
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. |
__call__
View source
__call__( w )
Applies the constraint to the input weight variable.
By default, the inputs weight variable is not modified. Users should override this method to implement their own projection function.
Args |
w | Input weight variable. |
Returns |
Projected variable (by default, returns unmodified inputs). |
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 2024-06-07 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 2024-06-07 UTC."],[],[],null,["# tf.keras.constraints.NonNeg\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/constraints/constraints.py#L119-L125) |\n\nConstrains the weights to be non-negative.\n\nInherits From: [`Constraint`](../../../tf/keras/constraints/Constraint)\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tf.keras.constraints.non_neg`](https://www.tensorflow.org/api_docs/python/tf/keras/constraints/NonNeg)\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `from_config`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/constraints/constraints.py#L59-L77) \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 [`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/v3.3.3/keras/src/constraints/constraints.py#L48-L57) \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\n\n### `__call__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/constraints/constraints.py#L123-L125) \n\n __call__(\n w\n )\n\nApplies the constraint to the input weight variable.\n\nBy default, the inputs weight variable is not modified.\nUsers should override this method to implement their own projection\nfunction.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----|------------------------|\n| `w` | Input weight variable. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| Projected variable (by default, returns unmodified inputs). ||\n\n\u003cbr /\u003e"]]