美文网首页
tensorflow矩阵扩充

tensorflow矩阵扩充

作者: ClarenceHoo | 来源:发表于2017-12-27 15:17 被阅读0次

a 的形状为([3,1,3,3,3])
需要在维度axis=1上扩充a至c=[3,8,3,3,3]
由于tensorflow的矩阵在某一维度做切片比较麻烦,采用了如下方法
a = 10*tf.random_normal([3,3,3,3])
b = tf.expand_dims(a,axis=1)
e = b
for i in range(8-1):
e = tf.concat([e,b],axis=1)
with tf.Session() as sess:
aa = sess.run(e)
print(aa.shape)
输出为[3,8,3,3,3]

相关文章

网友评论

      本文标题:tensorflow矩阵扩充

      本文链接:https://www.haomeiwen.com/subject/wieugxtx.html