Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variational parameter noise #240

Closed
albertz opened this issue Nov 11, 2022 · 1 comment
Closed

Variational parameter noise #240

albertz opened this issue Nov 11, 2022 · 1 comment

Comments

@albertz
Copy link
Member

albertz commented Nov 11, 2022

E.g. Lingvo has this, and they say it's important for bigger models or smaller datasets.

We also have it in RETURNN as param_variational_noise option for a layer.
However, here it makes sense to reimplement it.

Related: Weight dropout (#100), weight norm (#91)

The implementation in RETURNN:

      # Only apply this if we get a variable. Otherwise, maybe variational noise was already applied
      # (by some parent var scope), and we don't want to apply it twice.
      if param_variational_noise and param.dtype.is_floating and isinstance(param, tf.Variable):
        with default_control_flow_ctx():  # make independent from loop/cond
          with reuse_name_scope_of_tensor(param, postfix="_variational_noise", add_tensor_name=True):
            param = self.network.cond_on_train(
              fn_train=lambda: param + tf_compat.v1.random_normal(
                tf.shape(param), dtype=param.dtype.base_dtype,
                stddev=param_variational_noise,
                seed=self.network.random.randint(2 ** 31)),
              fn_eval=lambda: param)

In Lingvo:
https://github.com/tensorflow/lingvo/blob/65699192ba14521f330a1cae16141433453f1cbf/lingvo/tasks/asr/params/librispeech.py#L139
https://github.com/tensorflow/lingvo/blob/65699192ba14521f330a1cae16141433453f1cbf/lingvo/core/py_utils.py#L3691

@albertz
Copy link
Member Author

albertz commented Nov 12, 2022

This is implemented now. See nn.variational_weight_noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant