tensorflow - 如何实现keras的summergewhith模式

标签 tensorflow concatenation keras

我想在 tensorflow 中实现merge([a, b], mode='sum')。 keras 中的 mode='sum'mode='concat' 有什么区别?

如何在tensorlfow中实现merge([a, b], mode='sum')

最佳答案

假设您有两个张量,例如 [1, 2] 和 [2, 3]。如果您使用 mode = 'concat' 它将连接它们并给出 [1, 2, 3, 4]。如果您使用 mode = 'sum' ,它将按元素相加并给出结果 [1 + 2, 3 + 2] = [3, 5]。 Sum 可以使用tensorflow中的+运算符或tf.add函数来实现。 concat 可以使用 tf.concat 函数在 tensorflow 中使用。

关于tensorflow - 如何实现keras的summergewhith模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39202450/

相关文章:

python - 将代码从 Tensorflow 1 迁移到 Tensorflow 2 时,如何处理属性错误 : 'Adam' object has no attribute 'compute_gradient' ?

python - 进行 train_step.run() 时出现 Tensorflow 错误

python-3.x - 使用 Keras 和 TensorFlow 后端可重现结果

MySQL CREATE TRIGGER,语法错误。我做错了什么?

python - 我如何知道我的神经网络模型是否过拟合(Keras)

python - Keras 合并 VS 连接,无法更新我的代码

Java字符串连接效率

c++ - C++ 介绍 : Concatenating strings and returning it in a function?

python - Keras 中具有余弦相似度的暹罗网络,损失为 'mse'(已更新)

tensorflow - 第一层 MLP 输出在一个 epoch 后为零