def get2d_deconv_output_size(input_height, input_width, filter_height,
filter_width, row_stride, col_stride, padding_type):
"""Returns the number of rows and columns in a convolution/pooling output."""
input_height = tensor_shape.as_dimension(input_height)
input_width = tensor_shape.as_dimension(input_width)
filter_height = tensor_shape.as_dimension(filter_height)
filter_width = tensor_shape.as_dimension(filter_width)
row_stride = int(row_stride)
col_stride = int(col_stride)
# Compute number of rows in the output, based on the padding.
if input_height.value is None or filter_height.value is None:
out_rows = None
elif padding_type == "VALID":
out_rows = (input_height.value - 1) * row_stride + filter_height.value
elif padding_type == "SAME":
out_rows = input_height.value * row_stride
else:
raise ValueError("Invalid value for padding: %r" % padding_type)
# Compute number of columns in the output, based on the padding.
if input_width.value is None or filter_width.value is None:
out_cols = None
elif padding_type == "VALID":
out_cols = (input_width.value - 1) * col_stride + filter_width.value
elif padding_type == "SAME":
out_cols = input_width.value * col_stride
return out_rows, out_cols
评论列表
文章目录