EmbeddingKFACFB
Inherits From: KroneckerProductFB
Defined in tensorflow/contrib/kfac/python/ops/fisher_blocks.py.
K-FAC FisherBlock for embedding layers.
This FisherBlock is similar to FullyConnectedKFACBasicFB, except that its input factor is approximated by a diagonal matrix. In the case that each example references exactly one embedding, this approximation is exact.
Does not support bias parameters.
num_registered_towers__init____init__(
layer_collection,
vocab_size
)
Creates a EmbeddingKFACFB block.
layer_collection: The collection of all layers in the K-FAC approximate Fisher information matrix to which this FisherBlock belongs.vocab_size: int. Size of vocabulary for this embedding layer.full_fisher_blockfull_fisher_block()
Explicitly constructs the full Fisher block.
Used for testing purposes. (In general, the result may be very large.)
The full Fisher block.
instantiate_factorsinstantiate_factors(
grads_list,
damping
)
Instantiate Kronecker Factors for this FisherBlock.
grads_list: List of list of Tensors. grads_list[i][j] is the gradient of the loss with respect to 'outputs' from source 'i' and tower 'j'. Each Tensor has shape [tower_minibatch_size, output_size].damping: 0-D Tensor or float. 'damping' * identity is approximately added to this FisherBlock's Fisher approximation.multiplymultiply(vector)
Multiplies the vector by the (damped) block.
vector: The vector (a Tensor or tuple of Tensors) to be multiplied.The vector left-multiplied by the (damped) block.
multiply_inversemultiply_inverse(vector)
Multiplies the vector by the (damped) inverse of the block.
vector: The vector (a Tensor or tuple of Tensors) to be multiplied.The vector left-multiplied by the (damped) inverse of the block.
multiply_matpowermultiply_matpower(
vector,
exp
)
Multiplies the vector by the (damped) matrix-power of the block.
vector: The vector (a Tensor or tuple of Tensors) to be multiplied.exp: A float representing the power to raise the block by before multiplying it by the vector.The vector left-multiplied by the (damped) matrix-power of the block.
register_additional_towerregister_additional_tower(
inputs,
outputs
)
register_inverseregister_inverse()
Registers a matrix inverse to be computed by the block.
register_matpowerregister_matpower(exp)
Registers a matrix power to be computed by the block.
exp: A float representing the power to raise the block by.tensors_to_compute_gradstensors_to_compute_grads()
Tensors to compute derivative of loss with respect to.
© 2018 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/contrib/kfac/fisher_blocks/EmbeddingKFACFB