Fix training when hist_size==0

This commit is contained in:
Matthew Honnibal 2017-10-05 21:52:28 -05:00
parent e25ffcb11f
commit fc06b0a333
1 changed files with 2 additions and 0 deletions

View File

@ -257,6 +257,8 @@ class Embed(Model):
def HistoryFeatures(nr_class, hist_size=8, nr_dim=8): def HistoryFeatures(nr_class, hist_size=8, nr_dim=8):
'''Wrap a model, adding features representing action history.''' '''Wrap a model, adding features representing action history.'''
if hist_size == 0:
return layerize(noop())
embed_tables = [Embed(nr_dim, nr_class, column=i, name='embed%d') embed_tables = [Embed(nr_dim, nr_class, column=i, name='embed%d')
for i in range(hist_size)] for i in range(hist_size)]
embed = concatenate(*embed_tables) embed = concatenate(*embed_tables)