本文整理匯總了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)