Skip to content

  • 体验新版
    • 正在加载...
  • 登录
  • PaddlePaddle
  • Paddle
  • Issue
  • #3070

P
Paddle
  • 项目概览

PaddlePaddle / Paddle
大约 2 年 前同步成功

通知 2325
Star 20933
Fork 5424
  • 代码
    • 文件
    • 提交
    • 分支
    • Tags
    • 贡献者
    • 分支图
    • Diff
  • Issue 1423
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 543
  • Wiki 0
    • Wiki
  • 分析
    • 仓库
    • DevOps
  • 项目成员
  • Pages
P
Paddle
  • 项目概览
    • 项目概览
    • 详情
    • 发布
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者
    • 分支图
    • 比较
  • Issue 1,423
    • Issue 1,423
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 543
    • 合并请求 543
  • Pages
  • 分析
    • 分析
    • 仓库分析
    • DevOps
  • Wiki 0
    • Wiki
  • 成员
    • 成员
  • 收起侧边栏
  • 动态
  • 分支图
  • 创建新Issue
  • 提交
  • Issue看板
已关闭
开放中
Opened 7月 26, 2017 by saxon_zh@saxon_zhGuest

Some notes about PaddlePaddle, hope someone can help me to refine it and add them into F&Q

Created by: lcy-seso

1. About paddle.layer.memory in PaddlePaddle

  • Every layer in PaddlePaddle has a unique name if the user does not name a layer explicitly, it will be named automatically.
  • Memory in PaddlePaddle is very like reference parameters C++. Itself is not a real layer, but points to a layer and retrieve whose output in the previous time step.
  • You have to explicitly give a name to the layer paddle.layer.memory points to, because paddle.layer.memory needs a layer's name to decide to retrieve which layer's output in previous time step.
  • In paddle.layer.memory, the name specified by the name parameter is not the name of the defined memory layer, but the name of the real layer memory points to.

2. About paddle.layer.dropout and paddle.attr.ExtraLayerAttribute(drop_rate=x)

  • I think for most layers, a better way to use dropout is to set the droprate in layer_attr (every layer in paddle.layer has this attribute) by using paddle.attr.ExtraLayerAttribute(drop_rate=0.5) as below:

    fc = paddle.layer.fc(
                input=input,
                bias_attr=paddle.attr.Param(initial_std=0.),
                param_attr=paddle.attr.Param(initial_std=5e-4),
                layer_attr=paddle.attr.ExtraLayerAttribute(drop_rate=0.5),
  • dropout in PaddlePaddle is actually implemented in activiation function, it is not a layer.

  • But paddle.layer.lstmemory, paddle.layer.grumemory, paddle.layer.recurrent are different, these layers does not activiate the output by calling the general activiation process, but implement the activiation process themselves. As a results, drop rate cannot be directly set in these layer.

  • paddle.layer.dropout actually defines a paddle.layer.add_to layer and set the drop rate in this layer. This is a little waste of memory because output value to drop is copied again and PaddlePaddle will not release the memory to improve the time efficiency. But if you want to drop a recurrent layer's output, you have to use paddle.layer.dropout.

3. About different recurrent layers in PaddlePaddle.

  • If you do not need explicit access to the intermedia values in a recurrent unit (hidden states, input-to-hidden mapping, memory cells and so on), I recommend using paddle.networks.simple_lstm or paddle.layer.lstmemory.

  • recurrent_group is useful in attention model or NTM.

  • In PaddlePaddle we have (here I take LSTM for example, GRU is the same):

    1. paddle.layer.lstmemory
    2. paddle.networks.simple_lstm
    3. paddle.networks.lstmemory_group
    4. paddle.networks.lstmemory_unit
    5. paddle.networks.bidirectional_lstm
  • The above recurrent layers can be categorized into two type:

    1. recurrent layer implemented by recurrent_group:
      • you can access to any intermedia values (hidden states, input-to-hidden mapping, memory cells and so on) a recurrent unit computes during one time step.
      • the above 3
    2. recurrent layer as a whole:
      • you can only access to its outputs.
      • the above 1 ~ 2, 5
    3. paddle.networks.lstmemory_unit is not a recurrent unit, it defines the computation an LSTM unit performed in one time step.
      • It only can be used as the step function in recurrent_group.
      • the above 4
  • The second type (recurrent layer as a whole) is more computation efficient because recurrent_group is made up of many basic layers (including add, element-wise multiplication, matrix multiplication and so on), while recurrent layer as a whole is carefully optimized for both CPU and GPU.

  • But all recurrent layers(simple rnn, GRU, LSTM) in PaddlePaddle leave the input-to-hidden mapping outside the recurrent layer to make a larger matrix for LSTM and GRU to accelerate the computation speed.

    • This is the diffences between paddle.layer.lstmmemory and paddle.network.simple_lstm. Specifically:
      • paddle.layer.lstmmemory is not the LSTM in textbook, it is a LSTM unit without input-to-hidden projection.
      • paddle.network.simple_lstm is a wrapper which just adds the input-to-hidden projection into paddle.layer.lstmmemory. It is the LSTM in textbook.
    • paddle.layer.lstmmemory and paddle.network.simple_lstm in PaddlePaddle is LSTM with peephole connections. Be careful to this, make sure you have known they have more parameters than LSTM without peep-hole connections.
指派人
分配到
无
里程碑
无
分配里程碑
工时统计
无
截止日期
无
标识: paddlepaddle/Paddle#3070
渝ICP备2023009037号

京公网安备11010502055752号

网络110报警服务 Powered by GitLab CE v13.7
开源知识
Git 入门 Pro Git 电子书 在线学 Git
Markdown 基础入门 IT 技术知识开源图谱
帮助
使用手册 反馈建议 博客
《GitCode 隐私声明》 《GitCode 服务条款》 关于GitCode
Powered by GitLab CE v13.7