Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Reduce usage of tf.contrib.layers #1350

Merged
merged 6 commits into from
Jan 11, 2019

Conversation

lgeiger
Copy link
Contributor

@lgeiger lgeiger commented Jan 7, 2019

This PR replaces tf.contrib.layers with their stable tf.layers and tf.initializers equivalents.

@googlebot googlebot added the cla: yes PR author has signed CLA label Jan 7, 2019
@lgeiger lgeiger closed this Jan 7, 2019
@lgeiger lgeiger reopened this Jan 7, 2019
@lgeiger lgeiger force-pushed the less-tf-contrib-layers branch from bb28e04 to 046329f Compare January 8, 2019 00:59
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)
Copy link
Contributor Author

@lgeiger lgeiger Jan 8, 2019

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@afrozenator afrozenator left a 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

@afrozenator
Copy link
Contributor

Thanks a lot of this and other PRs @lgeiger - much appreciated!

@afrozenator afrozenator merged commit 57a9720 into tensorflow:master Jan 11, 2019
tensorflow-copybara pushed a commit that referenced this pull request Jan 11, 2019
PiperOrigin-RevId: 228806666
@lgeiger lgeiger deleted the less-tf-contrib-layers branch January 11, 2019 01:42
konradczechowski added a commit to deepsense-ai/tensor2tensor that referenced this pull request Jan 17, 2019
konradczechowski added a commit to deepsense-ai/tensor2tensor that referenced this pull request Jan 19, 2019
kpe pushed a commit to kpe/tensor2tensor that referenced this pull request Mar 2, 2019
* 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)
kpe pushed a commit to kpe/tensor2tensor that referenced this pull request Mar 2, 2019
PiperOrigin-RevId: 228806666
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has signed CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants