带有keras plot_model()cound的tf.math.add()未显示添加操作的两个输入

发布于 2025-01-31 19:00:25 字数 350 浏览 3 评论 0原文

如果我在模型中添加一行,例如p3 = tf.math.add(up_sample,x3_,name =“ up_sample + x3 _”) 在keras plot_model中,它只是显示第一个输入,如下图显示

[![Enter Image Description在此处] [1]] [1] [1]

我想知道如何显示add()函数的两个输入,tensorflow2 [1]: https://i.sstatic.net/zjjj9o.png

if I add one line to the model, such as p3 = tf.math.add(up_sample,x3_,name="up_sample + x3_")
in the keras plot_model, it just shows the first input,as the following image shows

[![enter image description here][1]][1]

I want to know how to show two inputs of the add() function with tensorflow2
[1]: https://i.sstatic.net/zjJ9o.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷了相思 2025-02-07 19:00:25

尝试在lambda layer中包装tf.math.add

import tensorflow as tf

input1 = tf.keras.layers.Input((2,))
input2 = tf.keras.layers.Input((2,))
output = tf.keras.layers.Lambda(lambda x: tf.math.add(x[0], x[1]), name='upsample')([input1, input2])

model = tf.keras.Model([input1, input2], output)
tf.keras.utils.plot_model(model, show_shapes=True)

”在此处输入图像说明”

Try wrapping the tf.math.add in a Lambda layer:

import tensorflow as tf

input1 = tf.keras.layers.Input((2,))
input2 = tf.keras.layers.Input((2,))
output = tf.keras.layers.Lambda(lambda x: tf.math.add(x[0], x[1]), name='upsample')([input1, input2])

model = tf.keras.Model([input1, input2], output)
tf.keras.utils.plot_model(model, show_shapes=True)

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文