269e11a506f1dfa80d95f27b3e2d3df845c80ae3,texar/modules/encoders/transformer_encoders.py,TransformerEncoder,__init__,#TransformerEncoder#Any#Any#Any#,34
Before Change
EncoderBase.__init__(self, hparams)
self._embedding = None
self._vocab_size = vocab_size
with tf.variable_scope(self.variable_scope):
if self._hparams.embedding_enabled:
if embedding is None and vocab_size is None:
raise ValueError("If `embedding` is not provided, "
"`vocab_size` must be specified.")
if isinstance(embedding, tf.Variable):
self._embedding = embedding
else:
self._embedding = layers.get_embedding(
self._hparams.embedding, embedding, vocab_size,
variable_scope="enc_embed")
embed_dim = self._hparams.embedding.dim
if self._hparams.zero_pad:
self._embedding = tf.concat((tf.zeros(shape=[1, embed_dim]),
self._embedding[1:, :]), 0)
if self._hparams.embedding.trainable:
self._add_trainable_variable(self._embedding)
@staticmethod
def default_hparams():
Returns a dictionary of hyperparameters with default values.
The dictionary has the following structure and default values.
After Change
self._embedding[1:, :]), 0)
if self._hparams.embedding.trainable:
self._add_trainable_variable(self._embedding)
if self._vocab_size is None:
self._vocab_size = self._embedding.get_shape().as_list()[0]
@staticmethod
def default_hparams():
Returns a dictionary of hyperparameters with default values.
The dictionary has the following structure and default values.
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances Project Name: asyml/texar
Commit Name: 269e11a506f1dfa80d95f27b3e2d3df845c80ae3
Time: 2017-12-09
Author: zhiting.hu@petuum.com
File Name: texar/modules/encoders/transformer_encoders.py
Class Name: TransformerEncoder
Method Name: __init__
Project Name: asyml/texar
Commit Name: 4287aef6a3a82436b4e3e156b22ede235eb4e6ba
Time: 2017-12-11
Author: shore@pku.edu.cn
File Name: texar/modules/decoders/transformer_decoders.py
Class Name: TransformerDecoder
Method Name: __init__
Project Name: tensorlayer/tensorlayer
Commit Name: 2e0f0929df4b01b269962a6423d6cb78b6d3da17
Time: 2018-12-04
Author: dhsig552@163.com
File Name: tensorlayer/layers/inputs.py
Class Name: EmbeddingInput
Method Name: __init__