def __init__(self, data_hparams, hparams=None): ModelBase.__init__(self, hparams) self._data_hparams = HParams(data_hparams, PairedTextData.default_hparams()) self._src_vocab = None self._tgt_vocab = None self._src_embedder = None self._tgt_embedder = None self._connector = None self._encoder = None self._decoder = None
def _input_fn(): data = PairedTextData(hparams) iterator = data.dataset.make_initializable_iterator() tf.add_to_collection(tf.GraphKeys.TABLE_INITIALIZERS, iterator.initializer) batch = iterator.get_next() features, labels = {}, {} for key, value in batch.items(): if key.startswith('source_'): features[key] = value else: labels[key] = value return features, labels
def _build_vocab(self): self._src_vocab, self._tgt_vocab = PairedTextData.make_vocab( self._data_hparams.source_dataset, self._data_hparams.target_dataset)