Created
November 29, 2018 19:03
-
-
Save aleksas/114bb1ca3f1788687b89d3a623b7bf87 to your computer and use it in GitHub Desktop.
Use encoder part from Tensor2Tensor transformer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tensor2tensor.models import transformer | |
import tensorflow as tf | |
hparams = transformer.transformer_base() | |
encoder = transformer.TransformerEncoder(hparams, mode=tf.estimator.ModeKeys.TRAIN) | |
#x = <your inputs, which should be of shape [batch_size, timesteps, 1, hparams.hidden_dim]> | |
#y = encoder({"inputs": x}) | |
# model_fn_body(features) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment