输入示例代码:
import tensorflow as tf from tensorflow import keras # Vector net = keras.layers.Dense(10) net.build((4, 8)) print(net.kernel) print(net.bias)
输出打印结果:
<tf.Variable 'kernel:0' shape=(8, 10) dtype=float32, numpy= array([[-0.1454469 , -0.13353938, 0.0148114 , -0.02513218, -0.13670841, -0.30207807, 0.04685295, 0.47797668, 0.34123123, 0.5593988 ], [-0.2173017 , 0.16555011, 0.15808946, 0.38894457, 0.27251107, -0.17880964, 0.27665257, 0.21354711, -0.0363853 , -0.1549784 ], [-0.46005934, -0.42392194, 0.04395181, -0.22937232, 0.28878307, -0.04343027, -0.2148321 , -0.36108726, 0.3033771 , 0.3759836 ], [-0.12115946, -0.3094625 , -0.50545156, -0.5156975 , -0.29974186, 0.06516838, -0.11144942, 0.14122474, 0.19736075, 0.48631787], [ 0.36187178, -0.20160082, 0.00370103, 0.39179885, -0.08576623, 0.2571134 , 0.47223556, 0.43600106, 0.06346703, 0.11621934], [-0.32191566, 0.39958787, -0.5066732 , -0.0265789 , -0.45043558, 0.25868195, 0.42228335, -0.07003105, -0.17230177, -0.3314101 ], [-0.11802283, 0.2691843 , -0.20074254, -0.05019581, -0.13276124, -0.17684138, 0.21805644, 0.42389882, -0.48757052, 0.5069295 ], [-0.18440807, -0.41915715, -0.50464535, -0.5677929 , -0.4431175 , -0.06128967, 0.5081208 , -0.3554923 , -0.26427248, 0.24391502]], dtype=float32)> <tf.Variable 'bias:0' shape=(10,) dtype=float32, numpy=array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], dtype=float32)>
shape(8,10) :表示8行10列。
shape(10,):表示1行10列,但10在‘,'前面。
网络世界,不加微信QQ手机,留言沟通
发表评论