hparams=None):
ModuleBase.__init__(self, hparams)
self._helper = None
self._initial_state = None
// Make rnn cell
with tf.variable_scope(self.variable_scope):
if cell is not None:
self._cell = cell
else:
self._cell = layers.get_rnn_cell(self._hparams.rnn_cell)
//self._external_cell_given = False
//if cell is not None:
// self._cell = cell
// self._external_cell_given = True
// Make the output layer
self._vocab_size = vocab_size
self._output_layer = output_layer
if output_layer is None:
if self._vocab_size is None:
raise ValueError(
"Either `output_layer` or `vocab_size` must be provided. "
"Set `output_layer=tf.identity` if no output layer is "
"wanted.")
with tf.variable_scope(self.variable_scope):
self._output_layer = tf.layers.Dense(units=self._vocab_size)
elif output_layer is not tf.identity:
if not isinstance(output_layer, tf.layers.Layer):
raise ValueError(
"`output_layer` must be either `tf.identity` or "