Skip to content
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

Replace objax with flax #68

Merged
merged 17 commits into from
Oct 27, 2021
Merged

Replace objax with flax #68

merged 17 commits into from
Oct 27, 2021

Conversation

crstngc
Copy link
Contributor

@crstngc crstngc commented Oct 26, 2021

Replaced Objax utilities with Flax.

@bwohlberg bwohlberg linked an issue Oct 26, 2021 that may be closed by this pull request
@bwohlberg bwohlberg added this to the Release 0.1.0 milestone Oct 26, 2021
@bwohlberg bwohlberg changed the title Cristina/flax Replace objax with flax Oct 26, 2021
@bwohlberg
Copy link
Collaborator

Directory misc/objax and content should be replaced with corresponding versions for flax.

@crstngc
Copy link
Contributor Author

crstngc commented Oct 26, 2021

Directory misc/objax and content should be replaced with corresponding versions for flax.

This folder should be deleted. For now we decided that no training scripts were going to be included in the release.

from scico.data import _objax_data_path
from scico.objax import DnCNN_Net
from scico.data import _flax_data_path
from scico.flax import DnCNNNet, load_weights
from scico.typing import JaxArray
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason for name change from DnCNN_Net to DnCNNNet? The former is a bit more readable.

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 am trying to follow the naming convention in the style guide. Underscores are not used in names of classes or names of exceptions.

Copy link
Collaborator

@bwohlberg bwohlberg Oct 27, 2021

Choose a reason for hiding this comment

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

Ah yes, good point. The three 'N's in a row aren't great for readability, so perhaps we should consider amending the style guide for such cases, but let's leave it as it is for now. FWIW, this issue has been encountered before, and one of the suggested solutions is a PEP-8 exception to include underscores.

@Michael-T-McCann @lukepfister : Any thoughts on this?

scico/flax.py Outdated
dtype=self.dtype,
)

# Processing
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is a bit mysterious. Also, see new comment style guidance in the style doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Edited comment to add more detail and follow style guide.

scico/flax.py Outdated
strides=self.strides,
name="conv_end",
)(y)
return base - y # Residual-like network
Copy link
Collaborator

Choose a reason for hiding this comment

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

According to new comment style, should be # residual-like network.

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.

deviation: L (low) = 0.06, M (mid) = 0.1, H (high) = 0.2, where the standard
deviations are with respect to data in the range [0, 1].
variant: Identify the DnCNN model to be used.
Options are '6L', '6M' (default), '6H', '17L', '17M',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Indentation looks wrong for an Args section, and the corresponding Parameters section in the docs doesn't render correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it. It seems OK in the documentation generated. Let me know if it is still not how it is supposed to be rendered.



def test_DnCNN_train(testobj):
# Test training flag for training
Copy link
Collaborator

Choose a reason for hiding this comment

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

Final "for training" intentional or typo?

Copy link
Contributor Author

@crstngc crstngc Oct 27, 2021

Choose a reason for hiding this comment

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

Intentional. A train flag argument is passed when applied the model. I am checking that the processing changes when the flag is True (i.e. set for training) or False (i.e. set for testing). I can remove this if deemed too confusing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps some rephrasing to minimize confusion, e.g. Test effect of training flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rephrased as suggested.

Copy link
Collaborator

@bwohlberg bwohlberg left a comment

Choose a reason for hiding this comment

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

Looks good.

@bwohlberg bwohlberg merged commit 4b8ae2e into main Oct 27, 2021
@bwohlberg bwohlberg deleted the cristina/flax branch October 27, 2021 17:31
bwohlberg added a commit that referenced this pull request Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace objax with flax
2 participants