本文整理汇总了Python中vgsl_input.ImageShape方法的典型用法代码示例。如果您正苦于以下问题:Python vgsl_input.ImageShape方法的具体用法?Python vgsl_input.ImageShape怎么用?Python vgsl_input.ImageShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vgsl_input
的用法示例。
在下文中一共展示了vgsl_input.ImageShape方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _ParseInputSpec
# 需要导入模块: import vgsl_input [as 别名]
# 或者: from vgsl_input import ImageShape [as 别名]
def _ParseInputSpec(input_spec):
"""Parses input_spec and returns the numbers obtained therefrom.
Args:
input_spec: Specification of the input layer. See Build.
Returns:
shape: ImageShape with the desired shape of the input.
Raises:
ValueError: if syntax is incorrect.
"""
pattern = re.compile(R'(\d+),(\d+),(\d+),(\d+)')
m = pattern.match(input_spec)
if m is None:
raise ValueError('Failed to parse input spec:' + input_spec)
batch_size = int(m.group(1))
y_size = int(m.group(2)) if int(m.group(2)) > 0 else None
x_size = int(m.group(3)) if int(m.group(3)) > 0 else None
depth = int(m.group(4))
if depth not in [1, 3]:
raise ValueError('Depth must be 1 or 3, had:', depth)
return vgsl_input.ImageShape(batch_size, y_size, x_size, depth)
示例2: testParseInputSpec
# 需要导入模块: import vgsl_input [as 别名]
# 或者: from vgsl_input import ImageShape [as 别名]
def testParseInputSpec(self):
"""The parser must return the numbers in the correct order.
"""
shape = vgsl_model._ParseInputSpec(input_spec='32,42,256,3')
self.assertEqual(
shape,
vgsl_input.ImageShape(
batch_size=32, height=42, width=256, depth=3))
# Nones must be inserted for zero sizes.
shape = vgsl_model._ParseInputSpec(input_spec='1,0,0,3')
self.assertEqual(
shape,
vgsl_input.ImageShape(
batch_size=1, height=None, width=None, depth=3))