expand_dim():
作用:
- 使用tf.expand_dims(input, axis=None, name=None, dim=None)函数来给矩阵增加一个维度。
例子:
# 't' is a tensor of shape [2]
shape(expand_dims(t, 0)) ==> [1, 2]
shape(expand_dims(t, 1)) ==> [2, 1]
shape(expand_dims(t, -1)) ==> [2, 1]
# 't2' is a tensor of shape [2, 3, 5]
shape(expand_dims(t2, 0)) ==> [1, 2, 3, 5]
shape(expand_dims(t2, 2)) ==> [2, 3, 1, 5]
shape(expand_dims(t2, 3)) ==> [2, 3, 5, 1]
说明:
- axis用来指定增加的一个维度中的元素包含的维度
本文详细解析了TensorFlow中expand_dim()函数的作用与用法,通过实例展示如何使用该函数为张量增加维度,适用于二维及多维张量操作,是深度学习模型构建中的重要技巧。
208

被折叠的 条评论
为什么被折叠?



