Commit 65da4505 authored by Sebastian Nickels's avatar Sebastian Nickels

Added dropout parameter for RNNs

parent 58436d17
Pipeline #226554 failed with stages
in 18 seconds
......@@ -53,10 +53,10 @@ class Reshape(gluon.HybridBlock):
class CustomRNN(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomRNN, self).__init__(**kwargs)
with self.name_scope():
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers,
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, activation='tanh', layout='NTC')
def hybrid_forward(self, F, data, state0):
......@@ -65,10 +65,10 @@ class CustomRNN(gluon.HybridBlock):
class CustomLSTM(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomLSTM, self).__init__(**kwargs)
with self.name_scope():
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers,
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0, state1):
......@@ -77,10 +77,10 @@ class CustomLSTM(gluon.HybridBlock):
class CustomGRU(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomGRU, self).__init__(**kwargs)
with self.name_scope():
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers,
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0):
......
......@@ -3,6 +3,7 @@
<#if mode == "ARCHITECTURE_DEFINITION">
self.${element.name} = CustomGRU(hidden_size=${element.units?c},
num_layers=${element.layers?c},
dropout=${element.dropout?c},
bidirectional=${element.bidirectional?string("True", "False")})
<#include "OutputShape.ftl">
<#elseif mode == "FORWARD_FUNCTION">
......
......@@ -3,6 +3,7 @@
<#if mode == "ARCHITECTURE_DEFINITION">
self.${element.name} = CustomLSTM(hidden_size=${element.units?c},
num_layers=${element.layers?c},
dropout=${element.dropout?c},
bidirectional=${element.bidirectional?string("True", "False")})
<#include "OutputShape.ftl">
<#elseif mode == "FORWARD_FUNCTION">
......
......@@ -3,6 +3,7 @@
<#if mode == "ARCHITECTURE_DEFINITION">
self.${element.name} = CustomRNN(hidden_size=${element.units?c},
num_layers=${element.layers?c},
dropout=${element.dropout?c},
bidirectional=${element.bidirectional?string("True", "False")})
<#include "OutputShape.ftl">
<#elseif mode == "FORWARD_FUNCTION">
......
......@@ -52,10 +52,10 @@ class Reshape(gluon.HybridBlock):
class CustomRNN(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomRNN, self).__init__(**kwargs)
with self.name_scope():
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers,
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, activation='tanh', layout='NTC')
def hybrid_forward(self, F, data, state0):
......@@ -64,10 +64,10 @@ class CustomRNN(gluon.HybridBlock):
class CustomLSTM(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomLSTM, self).__init__(**kwargs)
with self.name_scope():
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers,
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0, state1):
......@@ -76,10 +76,10 @@ class CustomLSTM(gluon.HybridBlock):
class CustomGRU(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomGRU, self).__init__(**kwargs)
with self.name_scope():
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers,
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0):
......
......@@ -52,10 +52,10 @@ class Reshape(gluon.HybridBlock):
class CustomRNN(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomRNN, self).__init__(**kwargs)
with self.name_scope():
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers,
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, activation='tanh', layout='NTC')
def hybrid_forward(self, F, data, state0):
......@@ -64,10 +64,10 @@ class CustomRNN(gluon.HybridBlock):
class CustomLSTM(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomLSTM, self).__init__(**kwargs)
with self.name_scope():
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers,
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0, state1):
......@@ -76,10 +76,10 @@ class CustomLSTM(gluon.HybridBlock):
class CustomGRU(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomGRU, self).__init__(**kwargs)
with self.name_scope():
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers,
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0):
......
......@@ -52,10 +52,10 @@ class Reshape(gluon.HybridBlock):
class CustomRNN(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomRNN, self).__init__(**kwargs)
with self.name_scope():
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers,
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, activation='tanh', layout='NTC')
def hybrid_forward(self, F, data, state0):
......@@ -64,10 +64,10 @@ class CustomRNN(gluon.HybridBlock):
class CustomLSTM(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomLSTM, self).__init__(**kwargs)
with self.name_scope():
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers,
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0, state1):
......@@ -76,10 +76,10 @@ class CustomLSTM(gluon.HybridBlock):
class CustomGRU(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomGRU, self).__init__(**kwargs)
with self.name_scope():
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers,
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0):
......
......@@ -52,10 +52,10 @@ class Reshape(gluon.HybridBlock):
class CustomRNN(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomRNN, self).__init__(**kwargs)
with self.name_scope():
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers,
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, activation='tanh', layout='NTC')
def hybrid_forward(self, F, data, state0):
......@@ -64,10 +64,10 @@ class CustomRNN(gluon.HybridBlock):
class CustomLSTM(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomLSTM, self).__init__(**kwargs)
with self.name_scope():
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers,
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0, state1):
......@@ -76,10 +76,10 @@ class CustomLSTM(gluon.HybridBlock):
class CustomGRU(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomGRU, self).__init__(**kwargs)
with self.name_scope():
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers,
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0):
......
......@@ -52,10 +52,10 @@ class Reshape(gluon.HybridBlock):
class CustomRNN(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomRNN, self).__init__(**kwargs)
with self.name_scope():
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers,
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, activation='tanh', layout='NTC')
def hybrid_forward(self, F, data, state0):
......@@ -64,10 +64,10 @@ class CustomRNN(gluon.HybridBlock):
class CustomLSTM(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomLSTM, self).__init__(**kwargs)
with self.name_scope():
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers,
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0, state1):
......@@ -76,10 +76,10 @@ class CustomLSTM(gluon.HybridBlock):
class CustomGRU(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomGRU, self).__init__(**kwargs)
with self.name_scope():
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers,
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0):
......
......@@ -52,10 +52,10 @@ class Reshape(gluon.HybridBlock):
class CustomRNN(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomRNN, self).__init__(**kwargs)
with self.name_scope():
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers,
self.rnn = gluon.rnn.RNN(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, activation='tanh', layout='NTC')
def hybrid_forward(self, F, data, state0):
......@@ -64,10 +64,10 @@ class CustomRNN(gluon.HybridBlock):
class CustomLSTM(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomLSTM, self).__init__(**kwargs)
with self.name_scope():
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers,
self.lstm = gluon.rnn.LSTM(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0, state1):
......@@ -76,10 +76,10 @@ class CustomLSTM(gluon.HybridBlock):
class CustomGRU(gluon.HybridBlock):
def __init__(self, hidden_size, num_layers, bidirectional, **kwargs):
def __init__(self, hidden_size, num_layers, dropout, bidirectional, **kwargs):
super(CustomGRU, self).__init__(**kwargs)
with self.name_scope():
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers,
self.gru = gluon.rnn.GRU(hidden_size=hidden_size, num_layers=num_layers, dropout=dropout,
bidirectional=bidirectional, layout='NTC')
def hybrid_forward(self, F, data, state0):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment