tf基础知识

import tensorflow as tf
import numpy as np
x=tf.constant([[[[[1,2],[3,4]],[[5,6],[7,8]]],[[[9,10],[11,12]],[[13,14],[15,16]]]]])

a=(1,2,2,2,2)
b = tf.stack([a[0],-1,a[-1]])
c = tf.reshape(x,b)
with tf.Session() as sess:
    print(b.eval())
    print(c.eval())

结果`

[ 1 -1  2]
[[[ 1  2]
  [ 3  4]
  [ 5  6]
  [ 7  8]
  [ 9 10]
  [11 12]
  [13 14]
  [15 16]]]

猜你喜欢

转载自blog.csdn.net/hanshihao1336295654/article/details/80473965