-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Reduce usage of tf.contrib.layers #1350
Reduce usage of tf.contrib.layers #1350
Conversation
bb28e04
to
046329f
Compare
net = tf.contrib.layers.conv2d_transpose( | ||
net, num_outputs, kernel_size=[3, 3], stride=stride, padding="valid") | ||
net = tf.layers.conv2d_transpose( | ||
net, num_outputs, (3, 3), strides=stride, activation=tf.nn.relu) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes the CycleGANUpsampleConv2dTranspose
test fail with AttributeError: 'tuple' object has no attribute 'ndims'
.
In the unit test cyclegan_upsample
gets called with a numpy input, tensorflow propably tries to interpret it as a list, which makes the test fail. Using a tensor as input would fix the unit test.
# this fails
upsampled_output = common_layers.cyclegan_upsample(random_input,
output_filters, stride, "conv2d_transpose")
# this works
upsampled_output = common_layers.cyclegan_upsample(tf.convert_to_tensor(random_input),
output_filters, stride, "conv2d_transpose")
@afrozenator Is this a bug that should be reported to the Tensorflow team, or is this expected behavior with tf.layers
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just fix the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 fixed it
I just wanted to bring this to your attention since the failure doesn't happen in the other upsampling tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets just fix the test and this will be good to go. Many many thanks for doing this! @lgeiger
Thanks a lot of this and other PRs @lgeiger - much appreciated! |
PiperOrigin-RevId: 228806666
This reverts commit 57a9720.
This reverts commit 57a9720.
* Replace tf.contrib.layers initializers with tf.initializers * Remove unused imports of tf.contrib.layers * tf.contrib.layers.conv2d -> tf.layers.conv2d * tf.contrib.layers.flatten -> tf.layers.flatten * tf.contrib.layers.fully_connected -> tf.layers.dense * Fix cyclegan_upsample unit test See tensorflow#1350 (comment)
PiperOrigin-RevId: 228806666
This PR replaces
tf.contrib.layers
with their stabletf.layers
andtf.initializers
equivalents.