tfp.experimental.nn.VariationalLayer
Stay organized with collections
Save and categorize content based on your preferences.
Base class for all variational layers.
Inherits From: Layer
tfp.experimental.nn.VariationalLayer(
posterior,
prior,
activation_fn=None,
posterior_value_fn=tfp.distributions.Distribution.sample
,
seed=None,
dtype=tf.float32,
validate_args=False,
name=None
)
Args |
posterior
|
...
|
prior
|
...
|
activation_fn
|
...
|
posterior_value_fn
|
...
|
seed
|
...
|
dtype
|
...
|
validate_args
|
...
|
name
|
Python str prepeneded to ops created by this object.
Default value: None (i.e., type(self).__name__ ).
|
Attributes |
activation_fn
|
|
also_track
|
|
dtype
|
|
name
|
Returns the name of this module as passed or determined in the ctor.
|
name_scope
|
Returns a tf.name_scope instance for this class.
|
non_trainable_variables
|
Sequence of non-trainable variables owned by this module and its submodules. |
posterior
|
|
posterior_value
|
|
posterior_value_fn
|
|
prior
|
|
submodules
|
Sequence of all sub-modules.
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
|
trainable_variables
|
Sequence of trainable variables owned by this module and its submodules.
|
validate_args
|
Python bool indicating possibly expensive checks are enabled.
|
variables
|
Sequence of variables owned by this module and its submodules. |
Methods
load
View source
load(
filename
)
save
View source
save(
filename
)
summary
View source
summary()
with_name_scope
@classmethod
with_name_scope(
method
)
Decorator to automatically enter the module name scope.
class MyModule(tf.Module):
@tf.Module.with_name_scope
def __call__(self, x):
if not hasattr(self, 'w'):
self.w = tf.Variable(tf.random.normal([x.shape[1], 3]))
return tf.matmul(x, self.w)
Using the above module would produce tf.Variable
s and tf.Tensor
s whose
names included the module name:
mod = MyModule()
mod(tf.ones([1, 2]))
<tf.Tensor: shape=(1, 3), dtype=float32, numpy=..., dtype=float32)>
mod.w
<tf.Variable 'my_module/Variable:0' shape=(2, 3) dtype=float32,
numpy=..., dtype=float32)>
Args |
method
|
The method to wrap.
|
Returns |
The original method wrapped such that it enters the module's name scope.
|
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 2023-11-21 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2023-11-21 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-11-21 UTC."],[],[]]