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

A wide pass on docs #657

Merged
merged 3 commits into from
Dec 2, 2020
Merged

A wide pass on docs #657

merged 3 commits into from
Dec 2, 2020

Conversation

avital
Copy link
Contributor

@avital avital commented Nov 20, 2020

  1. Added an autoencoder example to README to showcase modules with
    multiple methods

  2. Remove FAQ (it was all on the old API) -- we can consider bringing
    it back but best to just link to GitHub discussions if possible?

  3. Mark flax.nn as deprecated in more places and make it less visible

  4. Add deprecation notice in examples/README. (I will later remove the
    directory entirely but I wanted to separate those)

  5. Small adjustments

1. Added an autoencoder example to README to showcase modules with
   multiple methods

2. Remove FAQ (it was all on the old API) -- we can consider bringing
   it back but best to just link to GitHub discussions if possible?

3. Mark `flax.nn` as deprecated in more places and make it less visible

4. Add deprecation notice in examples/README. (I will later remove the
   directory entirely but I wanted to separate those)

5. Small adjustments
Copy link
Contributor

@BertrandRdp BertrandRdp left a comment

Choose a reason for hiding this comment

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

LGTM, that's a great refresh

@codecov-io
Copy link

codecov-io commented Nov 20, 2020

Codecov Report

Merging #657 (5e0ec16) into master (fbd3aec) will increase coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #657      +/-   ##
==========================================
+ Coverage   80.59%   80.67%   +0.08%     
==========================================
  Files          56       56              
  Lines        4241     4269      +28     
==========================================
+ Hits         3418     3444      +26     
- Misses        823      825       +2     
Impacted Files Coverage Δ
flax/linen/__init__.py 100.00% <100.00%> (ø)
flax/core/variables.py 0.00% <0.00%> (-100.00%) ⬇️
flax/optim/rmsprop.py 100.00% <0.00%> (ø)
flax/linen/attention.py 96.29% <0.00%> (ø)
flax/linen/dotgetter.py 70.21% <0.00%> (ø)
flax/linen/linear.py 99.45% <0.00%> (+<0.01%) ⬆️
flax/nn/base.py 92.46% <0.00%> (+0.01%) ⬆️
flax/optim/dynamic_scale.py 95.55% <0.00%> (+0.10%) ⬆️
flax/optim/base.py 81.56% <0.00%> (+0.10%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fbd3aec...5e0ec16. Read the comment docs.


## Official examples maintained by the Flax core team

This folder contains a collection of examples of implementations of various architectures and training procedures.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @andsteing -- I noticed that much of the content from this README hasn't been ported to our new documentation. Specifically:

  1. The "example matrix" diagram
  2. The description of goals for our examples
  3. Links and suggestions from the broader ecosystem (we may want to reach out to the package authors linked to from here so that all the packages are ported to Linen).

Was there an intention to add linen_examples/README.md, or to add back some of this content directly into RTD? Or something else? Happy to help, just wanted to see if there had been prior thinking about this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I will first update and move to linen_examples/README.md. Not sure if we want to have it in RTD or keep it as a README. Let's discuss this and move it in a second step if we decide for RTD.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Removed in #669

Copy link
Collaborator

@andsteing andsteing left a comment

Choose a reason for hiding this comment

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

Nice change !

| [seq2seq](seq2seq/README.md) | LSTM encoder/decoder for completing `42+1234=` sequences | On the fly data generation, LSTM state handling, simple code |
| [vae](vae/README.md) | Variational auto-encoder for binarized MNIST images | Tfds `binarized_mnist`, vmap, simple code |
| [wmt](wmt/README.md) | Transformer for translating en/de | Multi host SPMD, tfds `wmt1{4,7}_translate`, SentencePiece tokenization, checkpointing, dynamic bucketing, attention cache, packed sequences, recipe for TPU training on GCP |
You've caught us mid-way through our chrysallis! This directory
Copy link
Collaborator

Choose a reason for hiding this comment

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

:)
it's one "s", though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

one "l"!

README.md Outdated
@@ -10,20 +10,18 @@ Please check our [full documentation](https://flax.readthedocs.io/) website to l

**NOTE**: Flax is in use by a growing community
of researchers and engineers at Google who happily use Flax for their
daily research. The new Flax ["Linen" module API](https://github.com/google/flax/tree/master/flax/linen) is now stable and we recommend it for all new projects. The old `flax.nn` API will be deprecated. Please report
daily research. The new Flax ["Linen" module API](https://github.com/google/flax/tree/master/flax/linen/README.md) is now stable and we recommend it for all new projects. The old `flax.nn` API will be deprecated. Please report
Copy link
Collaborator

Choose a reason for hiding this comment

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

A general remark : I'm a big fan of wrapped paragraphs.

One of many advantages is that vscode side by side review is much easier when paragraphs are wrapped (due to microsoft/vscode#11387 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

We provide three examples using the Flax API: a simple multi-layer perceptron, a CNN and an auto-encoder.

To learn more about the `Module` abstraction, please check our [docs](https://flax.readthedocs.io/), or visit our
[patterns](https://flax.readthedocs.io/en/latest/patterns/flax_patterns.html) page for additional concrete demonstrations of best practices.
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about linking to
https://github.com/google/flax/blob/master/docs/notebooks/linen_intro.ipynb

people seem to have liked that notebook.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point

README.md Outdated
```py
class AutoEncoder(Module):
encoder_widths: Iterable
decoder_widths: Iterable
Copy link
Collaborator

Choose a reason for hiding this comment

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

MLP expects Sequence[int]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch

README.md Outdated
@@ -79,6 +76,30 @@ class CNN(nn.Module):
return x
```

```py
class AutoEncoder(Module):
encoder_widths: Iterable
Copy link
Collaborator

Choose a reason for hiding this comment

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

MLP expects Sequence[int]

README.md Outdated
class AutoEncoder(Module):
encoder_widths: Iterable
decoder_widths: Iterable
input_shape: Tuple = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not Tuple[int] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right

README.md Outdated
return self.decode(self.encode(x))

def encode(self, x):
assert x.shape[-len(self.input_shape):] == self.input_shape
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't we check

    assert x.shape[1:] == self.input_shape

if there are more than 1 dimensions in front of the expected self.input_shape, they will be flattened in the next line, and not maintained in the return value from decode()

(e.g. if input_shape=(3, 4) and x.shape=(5,10,3,4) then the return value from decode() will have shape=(50,3,4))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch.

@@ -3,7 +3,9 @@ flax.linen package
==================

.. currentmodule:: flax.linen
.. automodule:: flax.linen

Linen is the Flax Module system. Read more about our design goals in the `Linen README <https://github.com/google/flax/blob/master/flax/linen/README.md>`_.
Copy link
Collaborator

Choose a reason for hiding this comment

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

while reading through that file: what happened to the "various advanced use-cases" link?
https://github.com/google/flax/tree/master/linen_examples/core_design_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.

It's still there? see the bottom -- ""Design tests" used to ensure that our "functional core" supports various advanced use-cases, and that the mostly-syntactic-sugar Module abstraction doesn't get in the way"

docs/index.rst Outdated
@@ -6,20 +6,12 @@
Flax documentation
==================

Flax is a neural network library for JAX that is designed for flexibility and
Flax is a neural network library and ecosystem for JAX that is designed for flexibility. Flax
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you reformat this paragraph?
(vscode : install Rewrap and then Alt-Q)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done (I used Emacs alt-q for this, hope you're OK with that)

@copybara-service copybara-service bot merged commit 567dcfc into google:master Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants