Skip to content

Commit 98453e5

Browse files
authored
Merge branch 'main' into fix_dropout
2 parents af12949 + c628910 commit 98453e5

File tree

85 files changed

+682
-500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+682
-500
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ assignees: ''
1010
Provide as much information as possible. At least, this should include a description of your issue and steps to reproduce the problem. If possible also provide a summary of what steps or workarounds you have already tried.
1111

1212
### System information
13-
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
14-
- Flax, jax, jaxlib versions (obtain with `pip show flax jax jaxlib`:
15-
- Python version:
16-
- GPU/TPU model and memory:
17-
- CUDA version (if applicable):
13+
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
14+
- Flax, jax, jaxlib versions (obtain with `pip show flax jax jaxlib`:
15+
- Python version:
16+
- GPU/TPU model and memory:
17+
- CUDA version (if applicable):
1818

1919

2020
### Problem you have encountered:

.github/analytics/get_repo_metrics.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def parse_single_query(data, query_type):
110110
Parses the data returned by `send_query`
111111
112112
.. warning::
113-
113+
114114
Like `send_query`, the logic here depends on the specific structure
115115
of the query (e.g. it must be an issue or PR query, and must have a
116116
total count).
@@ -206,7 +206,7 @@ def _get_pr_features(prs):
206206
time_labeled_or_assigned = None
207207
time_merged_or_closed = None
208208
time_review = None
209-
209+
210210
if pr["reviews"]["nodes"]:
211211
review = pr["reviews"]["nodes"][0]
212212
time_review = _to_datetime(review["createdAt"])
@@ -258,9 +258,9 @@ def _shift_n_months(date: datetime, n: int) -> datetime:
258258

259259

260260
def _rolling_window(
261-
df: pd.DataFrame,
262-
f: Callable[[pd.DataFrame], pd.Series],
263-
window_size: int = 6,
261+
df: pd.DataFrame,
262+
f: Callable[[pd.DataFrame], pd.Series],
263+
window_size: int = 6,
264264
step: int = 1,
265265
) -> pd.DataFrame:
266266
# start of month of the first issue

.github/analytics/issue_activity_since_date.gql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
# Queries all the issues in a repo. For each issue, we get some basic data such as
3-
# the number, state, labels, and title. The most important part is the 'timelineItems'
4-
# which are the events that happened to the issue, we can use the information about
3+
# the number, state, labels, and title. The most important part is the 'timelineItems'
4+
# which are the events that happened to the issue, we can use the information about
55
# the datetime about certain key events to define some metrics. Note that we are
66
# getting more information than is probably needed but its fine for now.
77
repository(owner: "_REPO_OWNER_", name: "_REPO_NAME_") {
@@ -52,7 +52,7 @@
5252
}
5353
}
5454
}
55-
}
55+
}
5656
}
5757
}
5858
}

.github/analytics/pr_data_query.gql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
query {
22
# Queries all the Pull Requests in a repo. For each issue, we get some basic data such as
3-
# the number, state, reviews, and title. The most important part is the 'timelineItems'
4-
# which are the events that happened to the issue, we can use the information about
3+
# the number, state, reviews, and title. The most important part is the 'timelineItems'
4+
# which are the events that happened to the issue, we can use the information about
55
# the datetime about certain key events to define some metrics. We also use the 'reviews'
6-
# as indicators for certain metrics. Note that we are getting more information than is
6+
# as indicators for certain metrics. Note that we are getting more information than is
77
# probably needed but its fine for now.
88
repository(owner:"_REPO_OWNER_", name:"_REPO_NAME_") {
99
pullRequests(first:100) {

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!--
44
5-
Great, you are contributing to Flax!
5+
Great, you are contributing to Flax!
66
77
But... please read the following carefully so we can make sure your PR is merged
88
easily.

.github/workflows/build.yml

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,21 @@ on:
1313
- main
1414

1515
jobs:
16-
pre-commit:
17-
name: Test pre-commit hooks
16+
cancel-previous:
17+
name: Cancel Previous Runs
1818
runs-on: ubuntu-latest
19-
timeout-minutes: 5
2019
steps:
2120
- name: Cancel previous
22-
uses: styfle/[email protected]
21+
uses: styfle/[email protected]
22+
if: ${{github.ref != 'refs/head/main'}}
2323
with:
2424
access_token: ${{ github.token }}
25-
if: ${{github.ref != 'refs/head/main'}}
25+
workflow_id: ${{ github.event.workflow.id }}
26+
all_but_latest: true
27+
pre-commit:
28+
name: Test pre-commit hooks
29+
runs-on: ubuntu-latest
30+
steps:
2631
- uses: actions/checkout@v3
2732
- name: Set up Python 3.8
2833
uses: actions/setup-python@v3
@@ -33,17 +38,13 @@ jobs:
3338
name: Check commit count
3439
runs-on: ubuntu-latest
3540
steps:
36-
- name: Cancel previous
37-
uses: styfle/[email protected]
38-
with:
39-
access_token: ${{ github.token }}
4041
- uses: actions/checkout@v2
4142
# We allow at most 5 commits in a branch to ensure our CI doesn't break.
4243
- name: Check commit count in PR
4344
if: always()
4445
shell: bash
4546
run: |
46-
set -x
47+
set -x
4748
# $GITHUB_REF is in format `refs/heads/<branch_name>`. We fetch it under
4849
# the name `commit-count` so we can refer to it below.
4950
# Do an unshallow fetch so we retrieve all commits (this is necessary
@@ -59,8 +60,27 @@ jobs:
5960
echo "See $url for help on how to resolve this."
6061
exit 1
6162
fi
63+
test-import:
64+
name: Test import standalone
65+
runs-on: ubuntu-latest
66+
strategy:
67+
matrix:
68+
python-version: [3.7, 3.8, 3.9]
69+
steps:
70+
- uses: actions/checkout@v2
71+
- name: Set up Python ${{ matrix.python-version }}
72+
uses: actions/setup-python@v1
73+
with:
74+
python-version: ${{ matrix.python-version }}
75+
- name: Install standalone dependencies only
76+
run: |
77+
pip install .
78+
- name: Test importing Flax
79+
run: |
80+
python -c "import flax"
6281
tests:
6382
name: Run Tests
83+
needs: [cancel-previous, pre-commit, commit-count, test-import]
6484
runs-on: ubuntu-latest
6585
strategy:
6686
matrix:
@@ -72,10 +92,6 @@ jobs:
7292
- test-type: pytype
7393
python-version: 3.8
7494
steps:
75-
- name: Cancel previous
76-
uses: styfle/[email protected]
77-
with:
78-
access_token: ${{ github.token }}
7995
- uses: actions/checkout@v2
8096
- name: Set up Python ${{ matrix.python-version }}
8197
uses: actions/setup-python@v1
@@ -121,23 +137,3 @@ jobs:
121137
"description": "'$status'",
122138
"context": "github-actions/Build"
123139
}'
124-
test-import:
125-
name: Test import standalone
126-
runs-on: ubuntu-latest
127-
strategy:
128-
matrix:
129-
python-version: [3.7, 3.8, 3.9]
130-
steps:
131-
- uses: actions/checkout@v2
132-
- name: Set up Python ${{ matrix.python-version }}
133-
uses: actions/setup-python@v1
134-
with:
135-
python-version: ${{ matrix.python-version }}
136-
- name: Install standalone dependencies only
137-
run: |
138-
pip install .
139-
- name: Test importing Flax
140-
run: |
141-
python -c "import flax"
142-
143-

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ repos:
1313
hooks:
1414
- id: jupytext
1515
args: [--sync]
16+
- repo: https://github.com/pre-commit/pre-commit-hooks
17+
rev: v4.3.0
18+
hooks:
19+
- id: trailing-whitespace

.readthedocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ sphinx:
1212
# Optionally build your docs in additional formats such as PDF and ePub
1313
formats:
1414
- htmlzip
15+
- epub
16+
- pdf
1517

1618
# Optionally set the version of Python and requirements required to build your docs
1719
python:

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ New features:
5353
- Added async option to `save_checkpoints()` on single-process scenario.
5454
- Improved documentation pages.
5555

56-
Bug fixes:
56+
Bug fixes:
5757
- Fixed variable aliasing in put_variable
5858
- Fixed missing passthrough of nn.scan unroll arg
5959
- Fixed the MNIST example

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ To upgrade to the latest version of Flax, you can use:
8787

8888
## What does Flax look like?
8989

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

9292
To learn more about the `Module` abstraction, see our [docs](https://flax.readthedocs.io/), our [broad intro to the Module abstraction](https://github.com/google/flax/blob/main/docs/notebooks/linen_intro.ipynb). For additional concrete demonstrations of best practices, see our
93-
[HOWTO guides](https://flax.readthedocs.io/en/latest/howtos.html).
93+
[guides](https://flax.readthedocs.io/en/latest/guides/index.html) and
94+
[advanced topics documentation](https://flax.readthedocs.io/en/latest/advanced_topics/index.html).
9495

9596
```py
9697
from typing import Sequence
@@ -174,11 +175,11 @@ decoded = model.apply(variables, encoded, method=model.decode)
174175

175176
## 🤗 Hugging Face
176177

177-
In-detail examples to train and evaluate a variety of Flax models for
178-
Natural Language Processing, Computer Vision, and Speech Recognition are
178+
In-detail examples to train and evaluate a variety of Flax models for
179+
Natural Language Processing, Computer Vision, and Speech Recognition are
179180
actively maintained in the [🤗 Transformers repository](https://github.com/huggingface/transformers/tree/master/examples/flax).
180181

181-
As of October 2021, the [19 most-used Transformer architectures](https://huggingface.co/transformers/#supported-frameworks) are supported in Flax
182+
As of October 2021, the [19 most-used Transformer architectures](https://huggingface.co/transformers/#supported-frameworks) are supported in Flax
182183
and over 5000 pretrained checkpoints in Flax have been uploaded to the [🤗 Hub](https://huggingface.co/models?library=jax&sort=downloads).
183184

184185
## Citing Flax

dev/.devcontainer/devcontainer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"context": "..",
66
"dockerFile": "Dockerfile",
77

8-
// Use 'settings' to set *default* container specific settings.json values on container create.
8+
// Use 'settings' to set *default* container specific settings.json values on container create.
99
// You can edit these settings after create using File > Preferences > Settings > Remote.
10-
"settings": {
10+
"settings": {
1111
"terminal.integrated.shell.linux": "/bin/bash",
1212
"python.pythonPath": "/usr/local/bin/python",
1313
"python.linting.enabled": true,
@@ -24,7 +24,7 @@
2424
"runArgs": ["-v", "${env:HOME}${env:USERPROFILE}/.ssh:/root/.ssh-localhost:ro"],
2525
"postCreateCommand": "sudo cp -r /root/.ssh-localhost ~/.ssh && sudo chown -R $(id -u):$(id -g) ~/.ssh && chmod 700 ~/.ssh && chmod 600 ~/.ssh/* && pip install -e ./flax",
2626

27-
// Uncomment the next line to have VS Code connect as an existing non-root user in the container.
27+
// Uncomment the next line to have VS Code connect as an existing non-root user in the container.
2828
// On Linux, by default, the container user's UID/GID will be updated to match your local user. See
2929
// https://aka.ms/vscode-remote/containers/non-root for details on adding a non-root user if none exist.
3030
// "remoteUser": "vscode",

docs/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use the following notation:
4545
#
4646
# def sum(a, b):
4747
# return a + b
48-
#
48+
#
4949
# sum(0, 1)
5050
```
5151

@@ -87,19 +87,19 @@ You can use the second method if the `path_to_obj` is very long. Some examples:
8787
# :func:`my_func`
8888

8989
# Create a reference "Module.apply()" to method flax.linen.Module.apply.
90-
# :meth:`Module.apply() <flax.linen.Module.apply>` #
91-
```
90+
# :meth:`Module.apply() <flax.linen.Module.apply>` #
91+
```
9292

9393
To creata a hyperlink, use the following syntax:
9494
```bash
95-
# Note the double underscore at the end:
95+
# Note the double underscore at the end:
9696
# `Link to Google <http://www.google.com>`__
9797
```
9898

9999
### How to specify arguments for classes and methods
100100

101101
* Class attributes should be specified using the `Attributes:` tag.
102-
* Method argument should be specified using the `Args:` tags.
102+
* Method argument should be specified using the `Args:` tags.
103103
* All attributes and arguments should have types.
104104

105105
Here is an example from our library:

docs/_ext/codediff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ def _code_block(self, lines):
7575

7676
def _tabs(self, *contents: Tuple[str, List[str]], sync):
7777
output = ['.. tab-set::'] + [' ']
78-
78+
7979
for title, content in contents:
8080
output += [f' .. tab-item:: {title}']
81-
81+
8282
if sync:
8383
key = title.strip()
8484
output += [f' :sync: {key}']

docs/_ext/codediff_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CodeDiffTest(absltest.TestCase):
2424
def test_parse(self):
2525

2626
input_text = r'''@jax.jit #!
27-
def get_initial_params(key): #!
27+
def get_initial_params(key): #!
2828
init_val = jnp.ones((1, 28, 28, 1), jnp.float32)
2929
initial_params = CNN().init(key, init_val)['params']
3030
extra_line

docs/_templates/autosummary/flax_module.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
{% block methods %}
99

10-
.. automethod:: __call__
11-
10+
.. automethod:: __call__
11+
1212
{% if methods %}
1313
.. rubric:: Methods
1414

0 commit comments

Comments
 (0)