2020
09-29
09-29
Python3 Tensorlfow:增加或者减小矩阵维度的实现
1.增加维度下面给出两个样例样例1:[1,2,3]==>[[1],[2],[3]]importtensorflowastfa=tf.constant([1,2,3])b=tf.expand_dims(a,1)withtf.Session()assess:a_,b_=sess.run([a,b])print('a:')print(a_)print('b:')print(b_)输出结果a:[123]b:[[1][2][3]]样例2:[1,2,3]==>[[1,2,3]]importtensorflowastfa=tf.constant([1,2,3])b=tf.expand_dims(a,0)withtf.Session()assess:a_,b_=se...
继续阅读 >