本文整理汇总了Python中keras.utils.conv_utils.conv_output_length方法的典型用法代码示例。如果您正苦于以下问题:Python conv_utils.conv_output_length方法的具体用法?Python conv_utils.conv_output_length怎么用?Python conv_utils.conv_output_length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keras.utils.conv_utils
的用法示例。
在下文中一共展示了conv_utils.conv_output_length方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compute_output_shape
# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import conv_output_length [as 别名]
def compute_output_shape(self, input_shape):
if self.data_format == 'channels_first':
rows = input_shape[2]
cols = input_shape[3]
elif self.data_format == 'channels_last':
rows = input_shape[1]
cols = input_shape[2]
rows = conv_utils.conv_output_length(rows, self.kernel_size[0],
self.padding,
self.strides[0])
cols = conv_utils.conv_output_length(cols, self.kernel_size[1],
self.padding,
self.strides[1])
if self.data_format == 'channels_first':
return (input_shape[0], self.filters, rows, cols)
elif self.data_format == 'channels_last':
return (input_shape[0], rows, cols, self.filters)
示例2: compute_output_shape
# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import conv_output_length [as 别名]
def compute_output_shape(self, input_shape):
if self.data_format == 'channels_first':
rows = input_shape[2]
cols = input_shape[3]
out_filters = input_shape[1] * self.depth_multiplier
elif self.data_format == 'channels_last':
rows = input_shape[1]
cols = input_shape[2]
out_filters = input_shape[3] * self.depth_multiplier
rows = conv_utils.conv_output_length(rows, self.kernel_size[0],
self.padding,
self.strides[0])
cols = conv_utils.conv_output_length(cols, self.kernel_size[1],
self.padding,
self.strides[1])
if self.data_format == 'channels_first':
return (input_shape[0], out_filters, rows, cols)
elif self.data_format == 'channels_last':
return (input_shape[0], rows, cols, out_filters)
示例3: compute_output_shape
# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import conv_output_length [as 别名]
def compute_output_shape(self, input_shape):
if self.data_format == 'channels_first':
rows = input_shape[2]
cols = input_shape[3]
out_filters = input_shape[1] * self.depth_multiplier
elif self.data_format == 'channels_last':
rows = input_shape[1]
cols = input_shape[2]
out_filters = input_shape[3] * self.depth_multiplier
rows = conv_utils.conv_output_length(rows, self.kernel_size[0],
self.padding, self.strides[0])
cols = conv_utils.conv_output_length(cols, self.kernel_size[1],
self.padding, self.strides[1])
if self.data_format == 'channels_first':
return (input_shape[0], out_filters, rows, cols)
elif self.data_format == 'channels_last':
return (input_shape[0], rows, cols, out_filters)
示例4: compute_output_shape
# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import conv_output_length [as 别名]
def compute_output_shape(self, input_shape):
if self.data_format == 'channels_first':
rows = input_shape[2]
cols = input_shape[3]
out_filters = input_shape[1] * self.depth_multiplier
elif self.data_format == 'channels_last':
rows = input_shape[1]
cols = input_shape[2]
out_filters = input_shape[3] * self.depth_multiplier
rows = conv_utils.conv_output_length(rows, self.kernel_size[0],
self.padding,
self.strides[0])
cols = conv_utils.conv_output_length(cols, self.kernel_size[1],
self.padding,
self.strides[1])
if self.data_format == 'channels_first':
return input_shape[0], out_filters, rows, cols
elif self.data_format == 'channels_last':
return input_shape[0], rows, cols, out_filters
示例5: compute_output_shape
# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import conv_output_length [as 别名]
def compute_output_shape(self, input_shape):
if self.data_format == 'channels_last':
space = input_shape[1:-1]
new_space = []
for i in range(len(space)):
new_dim = conv_utils.conv_output_length(
space[i],
self.kernel_size[i],
padding=self.padding,
stride=self.strides[i],
dilation=self.dilation_rate[i])
new_space.append(new_dim)
return (input_shape[0],) + tuple(new_space) + (self.filters,)
if self.data_format == 'channels_first':
space = input_shape[2:]
new_space = []
for i in range(len(space)):
new_dim = conv_utils.conv_output_length(
space[i],
self.kernel_size[i],
padding=self.padding,
stride=self.strides[i],
dilation=self.dilation_rate[i])
new_space.append(new_dim)
return (input_shape[0], self.filters) + tuple(new_space)
示例6: compute_output_shape
# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import conv_output_length [as 别名]
def compute_output_shape(self, input_shape):
if self.data_format == 'channels_last':
space = input_shape[1:-1]
new_space = []
for i in range(len(space)):
new_dim = conv_utils.conv_output_length(
space[i],
self.kernel_size[i],
padding=self.padding,
stride=self.strides[i],
dilation=self.dilation_rate[i])
new_space.append(new_dim)
return (input_shape[0],) + tuple(new_space) + (self.n_filters,)
if self.data_format == 'channels_first':
space = input_shape[2:]
new_space = []
for i in range(len(space)):
new_dim = conv_utils.conv_output_length(
space[i],
self.kernel_size[i],
padding=self.padding,
stride=self.strides[i],
dilation=self.dilation_rate[i])
new_space.append(new_dim)
return (input_shape[0], self.n_filters) + tuple(new_space)
示例7: compute_output_shape
# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import conv_output_length [as 别名]
def compute_output_shape(self, input_shape):
space = input_shape[1:-1]
new_space = []
for i in range(len(space)):
new_dim = conv_utils.conv_output_length(
space[i],
filter_size=1,
padding=self.padding,
stride=self.strides[i],
dilation=self.dilation_rate[i])
new_space.append(new_dim)
return (input_shape[0],) + tuple(new_space) + (self.filters,)
示例8: compute_output_shape
# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import conv_output_length [as 别名]
def compute_output_shape(self, input_shape):
space = input_shape[1:-1]
new_space = []
for i in range(len(space)):
new_dim = conv_utils.conv_output_length(
space[i],
self.kernel_size[i],
padding=self.padding,
stride=self.strides[i])
new_space.append(new_dim)
return (None, np.prod(new_space) * self.filters, self.dim_capsule)
示例9: compute_output_shape
# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import conv_output_length [as 别名]
def compute_output_shape(self, input_shape):
if self.data_format == 'channels_last':
space = input_shape[1:-1]
new_space = []
for i in range(len(space)):
new_dim = conv_utils.conv_output_length(
space[i],
self.kernel_size[i],
padding=self.padding,
stride=self.strides[i],
dilation=self.dilation_rate[i]
)
new_space.append(new_dim)
return (input_shape[0],) + tuple(new_space) + (2 * self.filters,)
if self.data_format == 'channels_first':
space = input_shape[2:]
new_space = []
for i in range(len(space)):
new_dim = conv_utils.conv_output_length(
space[i],
self.kernel_size[i],
padding=self.padding,
stride=self.strides[i],
dilation=self.dilation_rate[i])
new_space.append(new_dim)
return (input_shape[0],) + (2 * self.filters,) + tuple(new_space)
示例10: compute_output_shape
# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import conv_output_length [as 别名]
def compute_output_shape(self, input_shape):
if self.data_format == 'channels_last':
space = input_shape[1:-1]
new_space = []
for i in range(len(space)):
new_dim = conv_utils.conv_output_length(
space[i],
self.kernel_size[i],
padding=self.padding,
stride=self.strides[i],
dilation=self.dilation_rate[i]
)
new_space.append(new_dim)
return (input_shape[0],) + tuple(new_space) + (4 * self.filters,)
if self.data_format == 'channels_first':
space = input_shape[2:]
new_space = []
for i in range(len(space)):
new_dim = conv_utils.conv_output_length(
space[i],
self.kernel_size[i],
padding=self.padding,
stride=self.strides[i],
dilation=self.dilation_rate[i])
new_space.append(new_dim)
return (input_shape[0],) + (4 * self.filters,) + tuple(new_space)
开发者ID:Orkis-Research,项目名称:Quaternion-Convolutional-Neural-Networks-for-End-to-End-Automatic-Speech-Recognition,代码行数:28,代码来源:conv.py
示例11: compute_output_shape
# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import conv_output_length [as 别名]
def compute_output_shape(self, input_shape):
if isinstance(input_shape, list):
input_shape = input_shape[0]
length = input_shape[1]
if length:
length = conv_output_length(length + self.window_size - 1,
self.window_size, 'valid',
self.strides[0])
if self.return_sequences:
return (input_shape[0], length, self.units)
else:
return (input_shape[0], self.units)
示例12: test_conv_output_length
# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import conv_output_length [as 别名]
def test_conv_output_length():
assert conv_utils.conv_output_length(None, 7, 'same', 1) is None
assert conv_utils.conv_output_length(224, 7, 'same', 1) == 224
assert conv_utils.conv_output_length(224, 7, 'same', 2) == 112
assert conv_utils.conv_output_length(32, 5, 'valid', 1) == 28
assert conv_utils.conv_output_length(32, 5, 'valid', 2) == 14
assert conv_utils.conv_output_length(32, 5, 'causal', 1) == 32
assert conv_utils.conv_output_length(32, 5, 'causal', 2) == 16
assert conv_utils.conv_output_length(32, 5, 'full', 1) == 36
assert conv_utils.conv_output_length(32, 5, 'full', 2) == 18
with pytest.raises(AssertionError):
conv_utils.conv_output_length(32, 5, 'diagonal', 2)
示例13: test_conv_input_length
# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import conv_output_length [as 别名]
def test_conv_input_length():
assert conv_utils.conv_input_length(None, 7, 'same', 1) is None
assert conv_utils.conv_input_length(112, 7, 'same', 1) == 112
assert conv_utils.conv_input_length(112, 7, 'same', 2) == 223
assert conv_utils.conv_input_length(28, 5, 'valid', 1) == 32
assert conv_utils.conv_input_length(14, 5, 'valid', 2) == 31
assert conv_utils.conv_input_length(36, 5, 'full', 1) == 32
assert conv_utils.conv_input_length(18, 5, 'full', 2) == 31
with pytest.raises(AssertionError):
conv_utils.conv_output_length(18, 5, 'diagonal', 2)