因为乌鸦像写字台 2019-04-06 15:23 采纳率: 50%
浏览 1095
已采纳

RNN 展开实现LSTM按时间步迭代时,有必要令reuse=true么?

我看到很多样例代码中, 展开实现LSTM按时间步迭代时,都如下加上了一句

if timestep > 0:
    tf.get_variable_scope().reuse_variables()

我查了各类RNN CELL类的源代码,发现除了call函数外,还有build函数(此函数似乎是在创建所有的变量),且此函数只调用一次,并且是在call调用之前调用,并且查看源码注释时发现是这样写的:

    For backwards compatibility purposes, most RNNCell instances allow their call methods to instantiate variables via tf.get_variable. The underlying variable scope thus keeps track of any variables, and returning cached versions. This is atypical of tf.layer objects, which separate this part of layer building into a build method that is only called once.
    Here we provide a subclass for RNNCell objects that act exactly as Layer objects do. They must provide a build method and their call methods do not access Variables tf.get_variable

所以我个人认为这句不需要加,求各位帮忙解答下,该不该加这句话?

  • 写回答

1条回答

  • threenewbee 2019-04-06 16:19
    关注

    看你的数据是怎样的,如果每组数据之间在时序上独立,就不要reuse,否可可以use。简单来说,不用reuse,也就是不共享权值不会有什么大影响,但是错误用了它,会导致正确率不上升。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误