将 tensorflow DropoutWrapper 与 LSTMBlockFusedCell 一起使用 [英] Using tensorflow DropoutWrapper with LSTMBlockFusedCell

查看:54
本文介绍了将 tensorflow DropoutWrapper 与 LSTMBlockFusedCell 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 DropoutWrapper 与 LSTMBlockFusedCell 一起使用,如下所示:

I am trying to use DropoutWrapper with LSTMBlockFusedCell as follows:

cell = tf.contrib.rnn.LSTMBlockFusedCell(num_units,forget_bias)
cell = tf.contrib.rnn.DropoutWrapper(cell,dropout)

我得到一个例外,LSTMBlockFusedCell 不是 RNNCell

I get an exception that the LSTMBlockFusedCell is not an RNNCell

消息:参数单元格不是 RNNCell.这是在 DropoutWrapper 初始化期间从 _like_rnncell 引发的.

Message: The parameter cell is not a RNNCell. Which is raised form _like_rnncell during DropoutWrapper initialization.

它正在检查单元格上的那些属性:

It is checking for those proprieties on the cell:

""Checks that a given object is an RNNCell by using duck typing."""

  conditions = [hasattr(cell, "output_size"), hasattr(cell, "state_size"),
                hasattr(cell, "zero_state"), callable(cell)] 

LSTMBlockFusedCell 没有 output_size 、 state_size 或 zero_state 属性.

LSTMBlockFusedCell does not have output_size , state_size or zero_state properties.

我想知道这是一个错误还是他们没有将 LSTMBlockFusedCell 作为 RNNCell 处理的任何其他原因.

I wonder whether this is a bug or is their any other reason for not handling LSTMBlockFusedCell as an RNNCell.

推荐答案

问题 建议在输入上使用 tf.nn.dropout 作为解决方法,他们不打算在 LSTMBlockFusedCell 中实现 dropout 或修复 DropoutWrapper当时.但我认为 tf.layers.dropout 可能更容易使用,因为它提供了 training 参数.

The issue suggested using tf.nn.dropout on inputs as a workaround and they didn't plan to implement the dropout in LSTMBlockFusedCell or fix the DropoutWrapper at the time. But I think tf.layers.dropout may be easier to use since it provides the training argument.

这篇关于将 tensorflow DropoutWrapper 与 LSTMBlockFusedCell 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆