Skip to content

Commit ece38ba

Browse files
authored
Add section on training a neural network with PyTorch and xbatcher to user guide (#258)
1 parent 71d563f commit ece38ba

File tree

9 files changed

+519
-16
lines changed

9 files changed

+519
-16
lines changed

ci/requirements/doc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ dependencies:
1717
- sphinx-design
1818
- xarray
1919
# For examples
20-
- adlfs
20+
- s3fs
2121
- ipykernel
2222
- nbsphinx
2323
- netcdf4
2424
- pooch
2525
- zarr
26+
- pytorch
2627
# Editable xbatcher installation
2728
- pip
2829

ci/requirements/environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies:
99
- numpy
1010
- xarray
1111
# Dev dependencies
12-
- adlfs
12+
- s3fs
1313
- asv
1414
- pre-commit
1515
- pytest

doc/conf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@
109109

110110
# List of patterns, relative to source directory, that match files and
111111
# directories to ignore when looking for source files.
112-
exclude_patterns = ['_build', '**.ipynb_checkpoints']
112+
exclude_patterns = [
113+
'_build',
114+
'**.ipynb_checkpoints',
115+
'user-guide/create-fashion-mnist-dataset.ipynb',
116+
]
113117

114118
# The reST default role (used for this markup: `text`) to use for all
115119
# documents.

doc/demo.ipynb

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,11 @@
4747
"metadata": {},
4848
"outputs": [],
4949
"source": [
50-
"store = 'az://carbonplan-share/example_cmip6_data.zarr'\n",
50+
"store = 's3://carbonplan-share/xbatcher/example_cmip6_data.zarr'\n",
5151
"ds = xr.open_dataset(\n",
52-
" store,\n",
53-
" engine='zarr',\n",
54-
" chunks={},\n",
55-
" backend_kwargs={'storage_options': {'account_name': 'carbonplan'}},\n",
52+
" store, engine='zarr', chunks={}, backend_kwargs={'storage_options': {'anon': True}}\n",
5653
")\n",
5754
"\n",
58-
"# the attributes contain a lot of useful information, but clutter the print out when we inspect the outputs\n",
59-
"# throughout this demo, clearing it to avoid confusion\n",
60-
"ds.attrs = {}\n",
61-
"\n",
6255
"# inspect the dataset\n",
6356
"ds"
6457
]
@@ -393,7 +386,7 @@
393386
],
394387
"metadata": {
395388
"kernelspec": {
396-
"display_name": "Python 3.9.13 ('xbatcher-tests')",
389+
"display_name": "Python 3 (ipykernel)",
397390
"language": "python",
398391
"name": "python3"
399392
},
@@ -407,7 +400,7 @@
407400
"name": "python",
408401
"nbconvert_exporter": "python",
409402
"pygments_lexer": "ipython3",
410-
"version": "3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:14) \n[Clang 12.0.1 ]"
403+
"version": "3.11.9"
411404
},
412405
"vscode": {
413406
"interpreter": {

doc/user-guide/caching.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
"\n",
219219
"# Set up S3 filesystem (you'll need appropriate credentials)\n",
220220
"s3 = s3fs.S3FileSystem(anon=False)\n",
221-
"store = s3.get_mapper('s3://my-bucket/my-cache.zarr')\n",
221+
"cache = s3.get_mapper('s3://my-bucket/my-cache.zarr')\n",
222222
"\n",
223223
"# Use this cache with BatchGenerator\n",
224224
"gen_s3 = xbatcher.BatchGenerator(ds, input_dims={'lat': 10, 'lon': 10}, cache=cache)\n",

doc/user-guide/create-fashion-mnist-dataset.ipynb

Lines changed: 190 additions & 0 deletions
Large diffs are not rendered by default.

doc/user-guide/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ User Guide
66
:caption: Contents:
77

88
caching
9+
training-a-neural-network-with-Pytorch-and-xbatcher

0 commit comments

Comments
 (0)