## Class MultitaskOptimizerWrapper

Optimizer wrapper making all-zero gradients harmless.

This might be useful when a multi-task loss is used, and some components of the loss might be not present (e.g. masked out) in some training batches. Technically their gradient would be zero, which would normally affect the optimizer state (e.g. push running average to zero). However this is not the desired behaviour, since the missing loss component should be treated as unknown rather than zero.

This wrapper filters out all-zero gradient tensors, therefore preserving the optimizer state.

If gradient clipping by global norm is used, the provided function clip_gradients_by_global_norm should be used (and specified explicitly by the user). Otherwise the global norm would be underestimated because of all-zero tensors that should be ignored.

The gradient calculation and application are delegated to an underlying optimizer. The gradient application is altered only for all-zero tensors.

Example:

momentum_optimizer = tf.train.MomentumOptimizer(
learning_rate, momentum=0.9)
momentum_optimizer)
loss)


## Methods

### __init__

__init__(opt)


Constructor.

#### Args:

• opt: an instance of a class that implements tf.train.Optimizer.

### __getattr__

__getattr__(name)