[[["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-11-21 UTC."],[],[],null,["# tfp.experimental.nn.VariationalLayer\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/nn/variational_base.py#L53-L113) |\n\nBase class for all variational layers.\n\nInherits From: [`Layer`](../../../tfp/experimental/nn/Layer) \n\n tfp.experimental.nn.VariationalLayer(\n posterior,\n prior,\n activation_fn=None,\n posterior_value_fn=../../../tfp/distributions/Distribution#sample,\n seed=None,\n dtype=tf.float32,\n validate_args=False,\n name=None\n )\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------------|-------------------------------------------------------------------------------------------------------------|\n| `posterior` | ... |\n| `prior` | ... |\n| `activation_fn` | ... |\n| `posterior_value_fn` | ... |\n| `seed` | ... |\n| `dtype` | ... |\n| `validate_args` | ... |\n| `name` | Python `str` prepeneded to ops created by this object. Default value: `None` (i.e., `type(self).__name__`). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|---------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `activation_fn` | \u003cbr /\u003e \u003cbr /\u003e |\n| `also_track` | \u003cbr /\u003e \u003cbr /\u003e |\n| `dtype` | \u003cbr /\u003e \u003cbr /\u003e |\n| `name` | Returns the name of this module as passed or determined in the ctor. \u003cbr /\u003e | **Note:** This is not the same as the `self.name_scope.name` which includes parent module names. |\n| `name_scope` | Returns a [`tf.name_scope`](https://www.tensorflow.org/api_docs/python/tf/name_scope) instance for this class. |\n| `non_trainable_variables` | Sequence of non-trainable variables owned by this module and its submodules.**Note:** this method uses reflection to find variables on the current instance and submodules. For performance reasons you may wish to cache the result of calling this method if you don't expect the return value to change. |\n| `posterior` | \u003cbr /\u003e |\n| `posterior_value` | \u003cbr /\u003e \u003cbr /\u003e |\n| `posterior_value_fn` | \u003cbr /\u003e \u003cbr /\u003e |\n| `prior` | \u003cbr /\u003e \u003cbr /\u003e |\n| `submodules` | Sequence of all sub-modules. \u003cbr /\u003e Submodules are modules which are properties of this module, or found as properties of modules which are properties of this module (and so on). a = tf.Module() b = tf.Module() c = tf.Module() a.b = b b.c = c list(a.submodules) == [b, c] True list(b.submodules) == [c] True list(c.submodules) == [] True \u003cbr /\u003e |\n| `trainable_variables` | Sequence of trainable variables owned by this module and its submodules. \u003cbr /\u003e | **Note:** this method uses reflection to find variables on the current instance and submodules. For performance reasons you may wish to cache the result of calling this method if you don't expect the return value to change. |\n| `validate_args` | Python `bool` indicating possibly expensive checks are enabled. |\n| `variables` | Sequence of variables owned by this module and its submodules.**Note:** this method uses reflection to find variables on the current instance and submodules. For performance reasons you may wish to cache the result of calling this method if you don't expect the return value to change. |\n\nMethods\n-------\n\n### `load`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/nn/layers.py#L55-L56) \n\n load(\n filename\n )\n\n### `save`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/nn/layers.py#L52-L53) \n\n save(\n filename\n )\n\n### `summary`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/nn/layers.py#L49-L50) \n\n summary()\n\n### `with_name_scope`\n\n @classmethod\n with_name_scope(\n method\n )\n\nDecorator to automatically enter the module name scope. \n\n class MyModule(tf.Module):\n @tf.Module.with_name_scope\n def __call__(self, x):\n if not hasattr(self, 'w'):\n self.w = tf.Variable(tf.random.normal([x.shape[1], 3]))\n return tf.matmul(x, self.w)\n\nUsing the above module would produce [`tf.Variable`](https://www.tensorflow.org/api_docs/python/tf/Variable)s and [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor)s whose\nnames included the module name: \n\n mod = MyModule()\n mod(tf.ones([1, 2]))\n \u003ctf.Tensor: shape=(1, 3), dtype=float32, numpy=..., dtype=float32)\u003e\n mod.w\n \u003ctf.Variable 'my_module/Variable:0' shape=(2, 3) dtype=float32,\n numpy=..., dtype=float32)\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------|---------------------|\n| `method` | The method to wrap. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The original method wrapped such that it enters the module's name scope. ||\n\n\u003cbr /\u003e"]]