本文整理汇总了Python中tensorflow.python.ops.rnn_cell.DropoutWrapper方法的典型用法代码示例。如果您正苦于以下问题:Python rnn_cell.DropoutWrapper方法的具体用法?Python rnn_cell.DropoutWrapper怎么用?Python rnn_cell.DropoutWrapper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.python.ops.rnn_cell
的用法示例。
在下文中一共展示了rnn_cell.DropoutWrapper方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tensorflow.python.ops import rnn_cell [as 别名]
# 或者: from tensorflow.python.ops.rnn_cell import DropoutWrapper [as 别名]
def __init__(self, hidden_size, keep_prob):
"""
Inputs:
hidden_size: int. Hidden size of the RNN
keep_prob: Tensor containing a single scalar that is the keep probability (for dropout)
"""
self.hidden_size = hidden_size
self.keep_prob = keep_prob
self.rnn_cell_fw = rnn_cell.GRUCell(self.hidden_size)
self.rnn_cell_fw = DropoutWrapper(self.rnn_cell_fw, input_keep_prob=self.keep_prob)
self.rnn_cell_bw = rnn_cell.GRUCell(self.hidden_size)
self.rnn_cell_bw = DropoutWrapper(self.rnn_cell_bw, input_keep_prob=self.keep_prob)
示例2: _create_rnn_cell
# 需要导入模块: from tensorflow.python.ops import rnn_cell [as 别名]
# 或者: from tensorflow.python.ops.rnn_cell import DropoutWrapper [as 别名]
def _create_rnn_cell(self):
cell = GRUCell(self.cfg.num_units) if self.cfg.cell_type == "gru" else LSTMCell(self.cfg.num_units)
if self.cfg.use_dropout:
cell = DropoutWrapper(cell, output_keep_prob=self.keep_prob)
if self.cfg.use_residual:
cell = ResidualWrapper(cell)
return cell
示例3: _create_single_rnn_cell
# 需要导入模块: from tensorflow.python.ops import rnn_cell [as 别名]
# 或者: from tensorflow.python.ops.rnn_cell import DropoutWrapper [as 别名]
def _create_single_rnn_cell(self, num_units):
cell = GRUCell(num_units) if self.cfg["cell_type"] == "gru" else LSTMCell(num_units)
if self.cfg["use_dropout"]:
cell = DropoutWrapper(cell, output_keep_prob=self.rnn_keep_prob)
if self.cfg["use_residual"]:
cell = ResidualWrapper(cell)
return cell