本文整理匯總了Python中onmt.modules.WeightNorm.WeightNormConv2d方法的典型用法代碼示例。如果您正苦於以下問題:Python WeightNorm.WeightNormConv2d方法的具體用法?Python WeightNorm.WeightNormConv2d怎麽用?Python WeightNorm.WeightNormConv2d使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類onmt.modules.WeightNorm
的用法示例。
在下文中一共展示了WeightNorm.WeightNormConv2d方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from onmt.modules import WeightNorm [as 別名]
# 或者: from onmt.modules.WeightNorm import WeightNormConv2d [as 別名]
def __init__(self, input_size, width=3, dropout=0.2, nopad=False):
super(GatedConv, self).__init__()
self.conv = WeightNormConv2d(input_size, 2 * input_size,
kernel_size=(width, 1), stride=(1, 1),
padding=(width // 2 * (1 - nopad), 0))
init.xavier_uniform(self.conv.weight, gain=(4 * (1 - dropout))**0.5)
self.dropout = nn.Dropout(dropout)