Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132928 views
License: OTHER
1
import tensorflow as tf
2
3
def get_deconv2d_output_dims(input_dims, filter_dims, stride_dims, padding):
4
# Returns the height and width of the output of a deconvolution layer.
5
batch_size, input_h, input_w, num_channels_in = input_dims
6
filter_h, filter_w, num_channels_out = filter_dims
7
stride_h, stride_w = stride_dims
8
9
# Compute the height in the output, based on the padding.
10
if padding == 'SAME':
11
out_h = input_h * stride_h
12
elif padding == 'VALID':
13
out_h = (input_h - 1) * stride_h + filter_h
14
15
# Compute the width in the output, based on the padding.
16
if padding == 'SAME':
17
out_w = input_w * stride_w
18
elif padding == 'VALID':
19
out_w = (input_w - 1) * stride_w + filter_w
20
21
return [batch_size, out_h, out_w, num_channels_out]
22
23