Skip to content

Commit

Permalink
Merge pull request #957 from rizar/no_bias_shallow_energy_computer
Browse files Browse the repository at this point in the history
Optional bias in ShallowEnergyComputer
  • Loading branch information
rizar committed Jan 29, 2016
2 parents 96c0605 + 0966c01 commit 5a964e4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions blocks/bricks/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,20 @@ def get_dim(self, name):


class ShallowEnergyComputer(Sequence, Initializable, Feedforward):
"""A simple energy computer: first tanh, then weighted sum."""
"""A simple energy computer: first tanh, then weighted sum.
Parameters
----------
use_bias : bool, optional
Whether a bias should be added to the energies. Does not change
anything if softmax normalization is used to produce the attention
weights, but might be useful when e.g. spherical softmax is used.
"""
@lazy()
def __init__(self, **kwargs):
def __init__(self, use_bias=False, **kwargs):
super(ShallowEnergyComputer, self).__init__(
[Tanh().apply, Linear(use_bias=False).apply], **kwargs)
[Tanh().apply, Linear(use_bias=use_bias).apply], **kwargs)

@property
def input_dim(self):
Expand Down

0 comments on commit 5a964e4

Please sign in to comment.