在keras中使用哪些合并层? [英] Which merge layers to use in keras?

查看:88
本文介绍了在keras中使用哪些合并层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Keras有许多不同的合并输入的方式,例如Add()Subtract()Multiply()concatenate()等...

Keras has many different ways of merging inputs like Add(), Subtract(), Multiply(), concatenate(), etc...

它们是否都具有相同的效果,或者在某些情况下更可取?

Do they all have the same effect or are there situations where one is preferable?

推荐答案

这实际上取决于您要实现的目标,但简要地让我们看一下不同的合并层以及它们通常用于什么目的:

It really depends on what you are trying to achieve but briefly let's look at different merge layers and what they are often used for:

  • 添加加法是使用relu激活功能的网络的常见合并操作,因为和也为正,并且可以对OR操作进行编码.例如,您想使用深度网络来确定该答案的任何评论是否是肯定的,然后可以添加所有编码的表示形式.
  • 减与平方相结合,因此(x-y)^ 2用于等式关系, close 彼此之间是什么关系.这些会在注意力计算中弹出,图像中的该区域是否包含我要寻找的特征,可能会相减.
  • 相乘与减法相似,如果您具有从正切中说出的特征,则可以将它们明智地相乘以找到相似的特征.如果两者都是正数或负数,则乘法将为正数负数,否则,网络将很好地利用此信息.
  • 通常使用
  • 平均值进行级联交易,以免丢失信息,但是如果从数学上讲,使每个先前的计算分支具有相等的权重,则该问题有意义,那么您可以进行平均.例如,您可能想要找到一个段落的整体情绪,而不希望任何否定句影响中性段落.
  • MaxPooling 之类的池操作中弹出
  • maximum 在尺寸上实现一些不变性.在图像中,将猫归为猫并不重要,同样,如果您只想检测出异常,则在哪里发生异常也无关紧要.
  • 连接是最常见的,因为它可以让上游网络决定如何使用给定的信息.它用于收集信息,通常用于其他合并层的输出.因此,您可以计算乘法并与其输入[x, y, x*y]合并.默认情况下,它在双向中使用,以允许双向信息.
  • add Addition is a common merge operation for networks that use relu activation function as the sum will also be positive and can encode an OR operation. For example, you want to identify if any of the comments for this answer are positive using a deep network, then you can add all the encoded representations.
  • subtract Subtraction in conjunction with squaring so (x-y)^2 is used for equality relationships, how close is something to another. These pop up in attention calculations, does this region in the image contain features I'm looking for could be a subtraction.
  • multiply Similar to subtraction, if you have features say from a tanh, then you can multiply them element wise to find similar features. If both are positive or negative the multiplication will be positive negative otherwise, the networks use this information well.
  • average is often traded for concatenate not to lose information but if the problem mathematically makes sense to have each previous branch of computation to have equal weight then you average. For example, you might want to find the overall sentiment of a paragraph and don't want any single negative sentence to affect a neutral paragraph.
  • maximum pop up in pooling operations like MaxPooling and allow you to achieve some invariance over the dimension. In images it doesn't matter where the cat is to classify for cat, similarly it doesn't matter where the anomaly occurs if you just want to detect it.
  • concatenate is the most common because it lets the upstream network to decide how to use the given information. It is used to gather information and often outputs of other merge layers. So you can compute multiplication and merge with its inputs [x, y, x*y]. By default it is used in Bidirectional to let information from both directions.

这篇关于在keras中使用哪些合并层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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