Skip to content

Conversation

@kyleabeauchamp
Copy link
Contributor

As requested in #25.

The main reason this is WIP is that I had to skip a handful of tests that were incompatible with eager mode. I still need to wrap my head around some of the eager testing / gradient mechanics, so I might not be able to finish this myself.

Copy link
Member

@WindQAQ WindQAQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Kyle, thanks for the contribution! I leave some comments below and hope them could help you.

self.assertAllClose(interp_val[0, :, 0],
target_interpolation)

def test_nd_linear_interpolation_unspecified_shape(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use placeholder in the test case, we could test it with decorator test_utils.run_deprecated_v1.
Another way to test the shape of None at graph build time is #260 (comment).

_ = interpolate_spline(train_points_ph, train_values_ph_invalid,
query_points_ph, order, reg_weight)

def test_interpolation_gradient(self):
Copy link
Member

@WindQAQ WindQAQ May 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if tf.test.compute_gradient can help you. test_utils.run_deprecated_v1 could be a workaround though.

@kyleabeauchamp
Copy link
Contributor Author

Thanks for the comments, I believe I have addressed all three. On the third comment, I ended up switching to use GradientTape, which seems like the most natural thing to do moving forward in TF2. However, let me know if I'm mistaken there...

@seanpmorgan
Copy link
Member

@yhliang2018 Could you give this a review when time allows? Thanks.
cc @parth-p

@yhliang2018
Copy link

@seanpmorgan Sure, I will take a look.

Copy link

@yhliang2018 yhliang2018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@@ -0,0 +1,303 @@
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 2019

@@ -0,0 +1,365 @@
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 2019

@@ -0,0 +1,201 @@
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: same as above.

class _QuadraticPlusSinProblem1D(_InterpolationProblem):
"""1D interpolation problem used for regression testing."""
DATA_DIM = 1
HARDCODED_QUERY_VALUES = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to move all these test data to a util file, like test_util.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess my preference is to leave them where they are so that the the tests and the test constants are co-located...also that's how the code was in TF.


import tensorflow as tf
import tensorflow.compat.v1 as tf1 # TODO: locate placeholder
from tensorflow.python.training import momentum

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be replaced as tf1.train.MomentumOptimizer, as we try to avoid direct import as much as possible.

Do you need to make addons as TF 2.0 as possible? If so, you may want to check optimizer v2: https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/keras/optimizers/SGD

num_boundary_points=3)

loss = tf.reduce_mean(tf.abs(warped_image - image))
optimizer = momentum.MomentumOptimizer(0.001, 0.9)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tf1.train.MomentumOptimizer.

merged_control_point_flows: augmented set of control point flows
"""

batch_size = tensor_shape.dimension_value(control_point_locations.shape[0])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kyleabeauchamp kyleabeauchamp requested a review from qlzh727 as a code owner June 29, 2019 06:20
@kyleabeauchamp
Copy link
Contributor Author

OK I think I've addressed all the comments.

@kyleabeauchamp kyleabeauchamp requested a review from a team as a code owner June 30, 2019 18:19
@kyleabeauchamp
Copy link
Contributor Author

So I had to add scipy to the requirements. In previous commits, even in this PR, it was transitively included from the tensorflow install. However, it was missing in the latest couple of commits. For now, the easiest solution was to include it in the requirements.

@kyleabeauchamp kyleabeauchamp mentioned this pull request Jul 7, 2019
12 tasks
@kyleabeauchamp kyleabeauchamp changed the title [WIP] Implement sparse image warp Implement sparse image warp Jul 18, 2019
@kyleabeauchamp
Copy link
Contributor Author

OK, I resolved all conflicts again on this PR, so it should be all synced up for review/merge.

Copy link
Member

@seanpmorgan seanpmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Kyle! LGTM I'm not in love with binary test images as part of the repo, but it's easier than downloading and verifying the hash.

@seanpmorgan seanpmorgan merged commit 6ec28e5 into tensorflow:master Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants