20-p20_tf.reshape

import tensorflow as tf
import numpy as np


x = np.random.uniform(size=[2,3,4])
y = np.reshape(x,[2,12])

print(y.shape)

y =np.reshape(x,[24])
print(y.shape)#(24,)

y = np.reshape(x,[2,1,3,4])
print(y.shape)
y = np.reshape(x,[2,1,1,1,3,1,4,1,1])
print(y.shape)#(2, 1, 1, 1, 3, 1, 4, 1, 1)
#---------------------------------------

y = np.transpose(x,[0,2,1])
print(y.shape)#(2, 4, 3),维度序号
#print(y)
x =tf.random_uniform([2,3,4],0,1.0)
y = tf.reshape(x,[2,12])
y= tf.reshape(x,[2,1,1,1,3,1,4,1,1])

D:\Anaconda\python.exe D:/AI20/06_codes/deeplearning_20/p20.py
(2, 12)
(24,)
(2, 1, 3, 4)
(2, 1, 1, 1, 3, 1, 4, 1, 1)
(2, 4, 3)

Process finished with exit code 0

发布了88 篇原创文章 · 获赞 2 · 访问量 1295

猜你喜欢

转载自blog.csdn.net/HJZ11/article/details/104541407
20)
$20
20