import numpy as np
import keras.backend as k
import cv2
import tensorflow as tf
tt1 = K.variable(np.array([[[0, 22], [29, 38]], [[49, 33],[5, 3]],[[8,8],[9,9]]]))
tt2 = K.variable(np.array([[[55, 47], [88, 48]], [[28, 10], [15, 51]],[[5,5],[6,6]]]))
t1 = K.variable(np.array([[[1, 2], [2, 3]], [[4, 4], [5, 3]]]))
t2 = K.variable(np.array([[[7, 4], [8, 4]], [[2, 10], [15, 11]]]))
实验一
dd3 = K.concatenate([tt1 , tt2] , axis=0)
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
print(sess.run(dd3))
[[[ 0. 22.]
[29. 38.]]
[[49. 33.]
[ 5. 3.]]
[[ 8. 8.]
[ 9. 9.]]
[[55. 47.]
[88. 48.]]
[[28. 10.]
[15. 51.]]
[[ 5. 5.]
[ 6. 6.]]]
dd3_1 = K.concatenate([t1 , tt1] , axis=0)
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
print(sess.run(dd3_1))
[[[ 1. 2.]
[ 2. 3.]]
[[ 4. 4.]
[ 5. 3.]]
[[ 0. 22.]
[29. 38.]]
[[49. 33.]
[ 5. 3.]]
[[ 8. 8.]
[ 9. 9.]]]
dd3
<tf.Tensor 'concat_9:0' shape=(6, 2, 2) dtype=float32>
dd3_1
<tf.Tensor 'concat_10:0' shape=(5