获取动静态张量的shape
程序员文章站
2024-02-14 16:09:52
...
def combined_static_and_dynamic_shape(tensor):
"""Returns a list containing static and dynamic values for the dimensions.
Returns a list of static and dynamic values for shape dimensions. This is
useful to preserve static shapes when available in reshape operation.
Args:
tensor: A tensor of any type.
Returns:
A list of size tensor.shape.ndims containing integers or a scalar tensor.
"""
static_tensor_shape = tensor.shape.as_list()
dynamic_tensor_shape = tf.shape(tensor)
combined_shape = []
for index, dim in enumerate(static_tensor_shape):
if dim is not None:
combined_shape.append(dim)
else:
combined_shape.append(dynamic_tensor_shape[index])
return combined_shape
predictions.get_shape().assert_is_compatible_with(labels.get_shape())
推荐阅读
-
获取动静态张量的shape
-
PHP Pthread socket 获取全局静态对象里的对象值
-
PHP Pthread socket 获取全局静态对象里的对象值
-
Linux系统下设置静态IP或自动获取动态IP的简单方法
-
利用反射获取Java类中的静态变量名及变量值的简单实例
-
asp.net实现利用反射,泛型,静态方法快速获取表单值到Model的方法
-
asp.net实现利用反射,泛型,静态方法快速获取表单值到Model的方法
-
springboot如何获取相对路径文件夹下静态资源的方法
-
Tensorflow获取张量Tensor的具体维数实例
-
PowerShell脚本实现网卡DHCP自动获取IP地址、设置静态IP地址的方法