TOC
How Keras add two layers?
tf.keras.layers.add()
method can add two layer?
What it do is sum the values of corresponding positions in two layers.
For example:
input_shape = (1,2,3)
import tensorflow as tf
tf.enable_eager_execution()
print("----------x1 tensor-----------")
x1 = tf.random.uniform(input_shape, maxval=10, dtype=tf.dtypes.int32)
tf.print(x1);
print("----------x2 tensor-----------")
x2 = tf.random.uniform(input_shape, maxval=10, dtype=tf.dtypes.int32)
tf.print(x2);
print("----------add 2 tensors-----------")
y = tf.keras.layers.add([x1,x2])
tf.print(y);
Output: ———-x1 tensor———– [[[7 6 1] [5 7 2]]] ———-x2 tensor———– [[[0 7 8] [2 9 6]]] ———-add 2 tensors———– [[[7 13 9] [7 16 8]]]
「点个赞」
点个赞
使用微信扫描二维码完成支付
