Reputation: 1529
How can I convert this function to an equivalent tf.keras (Tensorflow 2.0) implementation?
def deconv2d(inputs,out_channels, name=None):
batch, in_height, in_width, in_channels = [int(d) for d in inputs.get_shape()]
filter = tf.get_variable(name + "filter", [4, 4, out_channels, in_channels], initializer= tf.variance_scaling_initializer())
return tf.nn.conv2d_transpose(inputs, filter, [batch, in_height * 2, in_width * 2, out_channels], strides=[1,2,2,1],
padding='SAME', name= name)
Upvotes: 1
Views: 328
Reputation: 4533
TensoFlow 2.0 has tf.keras.layers.Conv2DTranspose
. Keras is the default high level API for TF 2.0, but it still have tf.nn.conv2d_transpose
for low level applications
https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/keras/layers/Conv2DTranspose
Upvotes: 1