当前位置: 首页>>代码示例>>Python>>正文


Python common_layers.sru方法代码示例

本文整理汇总了Python中tensor2tensor.layers.common_layers.sru方法的典型用法代码示例。如果您正苦于以下问题:Python common_layers.sru方法的具体用法?Python common_layers.sru怎么用?Python common_layers.sru使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensor2tensor.layers.common_layers的用法示例。


在下文中一共展示了common_layers.sru方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: step_preprocess

# 需要导入模块: from tensor2tensor.layers import common_layers [as 别名]
# 或者: from tensor2tensor.layers.common_layers import sru [as 别名]
def step_preprocess(x, step, hparams):
  """Preprocess the input at the beginning of each step.

  Args:
    x: input tensor
    step: step
    hparams: model hyper-parameters

  Returns:
    preprocessed input.

  """
  original_channel_size = common_layers.shape_list(x)[-1]

  if hparams.add_position_timing_signal:
    x = add_position_timing_signal(x, step, hparams)

  if hparams.add_step_timing_signal:
    x = add_step_timing_signal(x, step, hparams)

  if ((hparams.add_position_timing_signal or hparams.add_position_timing_signal)
      and hparams.add_or_concat_timing_signal == "concat"):
    # linear projection to the original dimension of x
    x = common_layers.dense(
        x, original_channel_size, activation=None, use_bias=False)

  if hparams.add_sru:
    x = common_layers.sru(x)

  return x 
开发者ID:akzaidi,项目名称:fine-lm,代码行数:32,代码来源:universal_transformer_util.py

示例2: autoencoder_ordered_text

# 需要导入模块: from tensor2tensor.layers import common_layers [as 别名]
# 或者: from tensor2tensor.layers.common_layers import sru [as 别名]
def autoencoder_ordered_text():
  """Ordered discrete autoencoder model for text."""
  hparams = autoencoder_ordered_discrete()
  hparams.learning_rate_constant = 2.0
  hparams.learning_rate_warmup_steps = 2000
  hparams.bottleneck_bits = 1024
  hparams.batch_size = 2048
  hparams.autoregressive_mode = "sru"
  hparams.hidden_size = 256
  hparams.max_hidden_size = 4096
  hparams.bottleneck_warmup_steps = 10000
  hparams.discretize_warmup_steps = 15000
  return hparams 
开发者ID:akzaidi,项目名称:fine-lm,代码行数:15,代码来源:autoencoders.py

示例3: testSRU

# 需要导入模块: from tensor2tensor.layers import common_layers [as 别名]
# 或者: from tensor2tensor.layers.common_layers import sru [as 别名]
def testSRU(self):
    x = np.random.rand(5, 7, 3, 11)
    with self.test_session() as session:
      y = common_layers.sru(tf.constant(x, dtype=tf.float32))
      session.run(tf.global_variables_initializer())
      res = session.run(y)
    self.assertEqual(res.shape, (5, 7, 3, 11)) 
开发者ID:akzaidi,项目名称:fine-lm,代码行数:9,代码来源:common_layers_test.py


注:本文中的tensor2tensor.layers.common_layers.sru方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。