keras 图层类中缺少特定选项
我想在计算机视觉任务的深度学习架构中对两个 keras conv2d 层 (Ix,Iy) 的结果实现操作。操作如下:
G = np.hypot(Ix, Iy)
G = G / G.max() * 255
theta = np.arctan2(Iy, Ix)
我花了一些时间寻找keras提供的操作,但到目前为止还没有成功。其中,有一个“添加”功能,允许用户添加两个 conv2d 层的结果 (tf.keras.layers.Add(Ix,Iy)
)。但是,我想要进行毕达哥拉斯加法(第一行),然后进行 arctan2 运算(第三行)。
因此,理想情况下,如果已经由 keras 实现,它将如下所示:
tf.keras.layers.Hypot(Ix,Iy)
tf.keras.layers.Arctan2(Ix,Iy)
有谁知道是否可以在我的深度学习架构中实现这些功能?是否可以编写满足我的需求的自定义层?
I would like to implement operations on the results of two keras conv2d layers (Ix,Iy) in a deep learning architecture for a computer vision task. The operation looks as follows:
G = np.hypot(Ix, Iy)
G = G / G.max() * 255
theta = np.arctan2(Iy, Ix)
I've spent some time looking for operations provided by keras but did not have success so far. Among a few others, there's a "add" functionality that allows the user to add the results of two conv2d layers (tf.keras.layers.Add(Ix,Iy)
). However, I would like to have a Pythagorean addition (first line) followed by a arctan2 operation (third line).
So ideally, if already implemented by keras it would look as follows:
tf.keras.layers.Hypot(Ix,Iy)
tf.keras.layers.Arctan2(Ix,Iy)
Does anyone know if it is possible to implement those functionalities within my deep learning architecture? Is it possible to write custom layers that meet my needs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以为您的用例使用简单的 Lambda 层,尽管它们并不是绝对必要的:
You could probably use simple
Lambda
layers for your use case, although they are not absolutely necessary: