Skip to content

Commit

Permalink
ConvLayer, with_bias=True by default
Browse files Browse the repository at this point in the history
Fix #787.

Introduces new behavior version (#508).
  • Loading branch information
albertz committed Dec 7, 2021
1 parent c76487f commit e132494
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/configuration_reference/behavior_version.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ and not listing legacy/deprecated parameters.
Version History
---------------

Behavior version 10 (2021-12-07)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:class:`ConvLayer` use ``with_bias=True`` by default.

See issue `#787 <https://github.com/rwth-i6/returnn/issues/787>`__.

Behavior version 9 (2021-12-03)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
6 changes: 5 additions & 1 deletion returnn/tf/layers/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4319,6 +4319,7 @@ def __init__(self, filter_size, padding, strides=1, dilation_rate=1, groups=1,
:param dict[str,str]|None filter_perm: transposes the filter (input filter as layer)
:param LayerBase|None bias: if given, will not create an own parameter, but use this as the bias
"""
from returnn.util import BehaviorVersion
padding = padding.upper()
assert padding in ["SAME", "VALID"], "no other padding supported at the moment"
assert "out_type" not in kwargs, "don't set out_type explicitly for this layer"
Expand Down Expand Up @@ -4425,7 +4426,10 @@ def __init__(self, filter_size, padding, strides=1, dilation_rate=1, groups=1,
y = tf.reshape(y, tf.concat([extended_batch_shape, tf.shape(y)[1:]], axis=0))
# y shape is [batch] + dynamic_dims + [n_out].
if with_bias is NotSpecified:
with_bias = True if bias else False
if bias or BehaviorVersion.get() >= 10:
with_bias = True
else:
with_bias = False
if bias:
assert with_bias
self.bias_layer = None
Expand Down
2 changes: 1 addition & 1 deletion returnn/util/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class BehaviorVersion:
The version will be set after the config is defined at __main__.init_config() or Engine.__init__()
"""

_latest_behavior_version = 9
_latest_behavior_version = 10
_behavior_version = None # type: typing.Optional[int]

@classmethod
Expand Down

0 comments on commit e132494

Please sign in to comment.