Skip to content

check min size for visual encoders #3112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 20, 2019
Merged

Conversation

chriselion
Copy link
Contributor

@chriselion chriselion commented Dec 20, 2019

The visual encoders have a minimum usable size due to the strides. Currently, if you go below this size, we get an ugly looking exception in keras.

This PR adds a friendlier exception when you go under the min size, and adds tests to make sure the min is actually the min.

@chriselion chriselion requested a review from ervteng December 20, 2019 20:39
@@ -427,6 +438,17 @@ def create_resnet_visual_observation_encoder(
)
return hidden_flat

@staticmethod
def get_encoder_for_type(encoder_type: EncoderType) -> EncoderFunction:
ENCODER_FUNCTION_BY_TYPE = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't think I can make this dict a class member :/

enc_func(vis_input, 32, LearningModel.swish, 1, "test", False)

# Anything under the min size should raise an exception. If not, decrease the min size!
with pytest.raises(Exception):
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we except the specific exception (and check that it's the negative dimension issue) just in case the model has a different error?

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 don't think we need the exact type; the test is sufficient to make sure that size N works and N-1 doesn't. Besides, it's possible that different encoders would fail for different reasons.

Copy link
Contributor

@ervteng ervteng left a comment

Choose a reason for hiding this comment

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

👍

@chriselion chriselion merged commit 47625be into master Dec 20, 2019
@delete-merged-branch delete-merged-branch bot deleted the develop-MLA-485-min-visual-size branch December 20, 2019 21:34
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants