Skip to content

Commit 7567602

Browse files
authored
Add pip install keras-rs to all examples that need it. (#2102)
This is needed for the colabs to work.
1 parent 489038c commit 7567602

27 files changed

+163
-18
lines changed

examples/keras_rs/basic_retrieval.py

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
the necessary libraries.
7373
"""
7474

75+
"""shell
76+
pip install -q keras-rs
77+
"""
78+
7579
import os
7680

7781
os.environ["KERAS_BACKEND"] = "jax" # `"tensorflow"`/`"torch"`

examples/keras_rs/data_parallel_retrieval.py

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
JAX as your backend!
3030
"""
3131

32+
"""shell
33+
pip install -q keras-rs
34+
"""
35+
3236
import os
3337

3438
os.environ["KERAS_BACKEND"] = "jax"

examples/keras_rs/dcn.py

+4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
Let's set the backend to JAX, and get our imports sorted.
7777
"""
7878

79+
"""shell
80+
pip install -q keras-rs
81+
"""
82+
7983
import os
8084

8185
os.environ["KERAS_BACKEND"] = "jax" # `"tensorflow"`/`"torch"`

examples/keras_rs/deep_recommender.py

+4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
affects model performance.
7777
"""
7878

79+
"""shell
80+
pip install -q keras-rs
81+
"""
82+
7983
import os
8084

8185
os.environ["KERAS_BACKEND"] = "jax" # `"tensorflow"`/`"torch"`

examples/keras_rs/ipynb/basic_retrieval.ipynb

+11
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@
8484
"the necessary libraries."
8585
]
8686
},
87+
{
88+
"cell_type": "code",
89+
"execution_count": 0,
90+
"metadata": {
91+
"colab_type": "code"
92+
},
93+
"outputs": [],
94+
"source": [
95+
"!pip install -q keras-rs"
96+
]
97+
},
8798
{
8899
"cell_type": "code",
89100
"execution_count": 0,

examples/keras_rs/ipynb/data_parallel_retrieval.ipynb

+11
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@
4141
" JAX as your backend!"
4242
]
4343
},
44+
{
45+
"cell_type": "code",
46+
"execution_count": 0,
47+
"metadata": {
48+
"colab_type": "code"
49+
},
50+
"outputs": [],
51+
"source": [
52+
"!pip install -q keras-rs"
53+
]
54+
},
4455
{
4556
"cell_type": "code",
4657
"execution_count": 0,

examples/keras_rs/ipynb/dcn.ipynb

+11
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@
8888
"Let's set the backend to JAX, and get our imports sorted."
8989
]
9090
},
91+
{
92+
"cell_type": "code",
93+
"execution_count": 0,
94+
"metadata": {
95+
"colab_type": "code"
96+
},
97+
"outputs": [],
98+
"source": [
99+
"!pip install -q keras-rs"
100+
]
101+
},
91102
{
92103
"cell_type": "code",
93104
"execution_count": 0,

examples/keras_rs/ipynb/deep_recommender.ipynb

+11
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@
8888
"affects model performance."
8989
]
9090
},
91+
{
92+
"cell_type": "code",
93+
"execution_count": 0,
94+
"metadata": {
95+
"colab_type": "code"
96+
},
97+
"outputs": [],
98+
"source": [
99+
"!pip install -q keras-rs"
100+
]
101+
},
91102
{
92103
"cell_type": "code",
93104
"execution_count": 0,

examples/keras_rs/ipynb/listwise_ranking.ipynb

+11
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@
4545
"Let's begin by importing all the necessary libraries."
4646
]
4747
},
48+
{
49+
"cell_type": "code",
50+
"execution_count": 0,
51+
"metadata": {
52+
"colab_type": "code"
53+
},
54+
"outputs": [],
55+
"source": [
56+
"!pip install -q keras-rs"
57+
]
58+
},
4859
{
4960
"cell_type": "code",
5061
"execution_count": 0,

examples/keras_rs/ipynb/multi_task.ipynb

+11
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@
4949
"Let's start by importing the necessary packages."
5050
]
5151
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": 0,
55+
"metadata": {
56+
"colab_type": "code"
57+
},
58+
"outputs": [],
59+
"source": [
60+
"!pip install -q keras-rs"
61+
]
62+
},
5263
{
5364
"cell_type": "code",
5465
"execution_count": 0,

examples/keras_rs/ipynb/sas_rec.ipynb

+11
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@
3434
"Let's begin by importing all the necessary libraries."
3535
]
3636
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": 0,
40+
"metadata": {
41+
"colab_type": "code"
42+
},
43+
"outputs": [],
44+
"source": [
45+
"!pip install -q keras-rs"
46+
]
47+
},
3748
{
3849
"cell_type": "code",
3950
"execution_count": 0,

examples/keras_rs/ipynb/scann.ipynb

+1-11
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,7 @@
6464
},
6565
"outputs": [],
6666
"source": [
67-
"# ruff: noqa: E402"
68-
]
69-
},
70-
{
71-
"cell_type": "code",
72-
"execution_count": 0,
73-
"metadata": {
74-
"colab_type": "code"
75-
},
76-
"outputs": [],
77-
"source": [
67+
"!pip install -q keras-rs\n",
7868
"!pip install -q scann"
7969
]
8070
},

examples/keras_rs/ipynb/sequential_retrieval.ipynb

+11
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@
3333
"the necessary libraries."
3434
]
3535
},
36+
{
37+
"cell_type": "code",
38+
"execution_count": 0,
39+
"metadata": {
40+
"colab_type": "code"
41+
},
42+
"outputs": [],
43+
"source": [
44+
"!pip install -q keras-rs"
45+
]
46+
},
3647
{
3748
"cell_type": "code",
3849
"execution_count": 0,

examples/keras_rs/listwise_ranking.py

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
Let's begin by importing all the necessary libraries.
3434
"""
3535

36+
"""shell
37+
pip install -q keras-rs
38+
"""
39+
3640
import os
3741

3842
os.environ["KERAS_BACKEND"] = "jax" # `"tensorflow"`/`"torch"`

examples/keras_rs/md/basic_retrieval.md

+5
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ Let's begin by choosing JAX as the backend we want to run on, and import all
7575
the necessary libraries.
7676

7777

78+
```python
79+
!pip install -q keras-rs
80+
```
81+
82+
7883
```python
7984
import os
8085

examples/keras_rs/md/data_parallel_retrieval.md

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ Before we begin, let's note down a few things:
3232
JAX as your backend!
3333

3434

35+
```python
36+
!pip install -q keras-rs
37+
```
38+
39+
3540
```python
3641
import os
3742

examples/keras_rs/md/dcn.md

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ learnt important feature crosses.
7979
Let's set the backend to JAX, and get our imports sorted.
8080

8181

82+
```python
83+
!pip install -q keras-rs
84+
```
85+
86+
8287
```python
8388
import os
8489

examples/keras_rs/md/deep_recommender.md

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ We'll do this by building progressively more complex models to see how this
7979
affects model performance.
8080

8181

82+
```python
83+
!pip install -q keras-rs
84+
```
85+
86+
8287
```python
8388
import os
8489

examples/keras_rs/md/listwise_ranking.md

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ goal is to minimize the number of incorrectly ordered pairs.
3636
Let's begin by importing all the necessary libraries.
3737

3838

39+
```python
40+
!pip install -q keras-rs
41+
```
42+
43+
3944
```python
4045
import os
4146

examples/keras_rs/md/multi_task.md

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ user to a movie.
4040
Let's start by importing the necessary packages.
4141

4242

43+
```python
44+
!pip install -q keras-rs
45+
```
46+
47+
4348
```python
4449
import os
4550

examples/keras_rs/md/sas_rec.md

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ for the same sequential recommendation task.
2525
Let's begin by importing all the necessary libraries.
2626

2727

28+
```python
29+
!pip install -q keras-rs
30+
```
31+
32+
2833
```python
2934
import os
3035

examples/keras_rs/md/scann.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ also set the backend to JAX.
4949

5050

5151
```python
52-
# ruff: noqa: E402
53-
```
54-
55-
56-
```python
52+
!pip install -q keras-rs
5753
!pip install -q scann
5854
```
5955

examples/keras_rs/md/sequential_retrieval.md

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ Let's begin by choosing JAX as the backend we want to run on, and import all
2424
the necessary libraries.
2525

2626

27+
```python
28+
!pip install -q keras-rs
29+
```
30+
31+
2732
```python
2833
import os
2934

examples/keras_rs/multi_task.py

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
Let's start by importing the necessary packages.
3838
"""
3939

40+
"""shell
41+
pip install -q keras-rs
42+
"""
43+
4044
import os
4145

4246
os.environ["KERAS_BACKEND"] = "jax" # `"tensorflow"`/`"torch"`

examples/keras_rs/sas_rec.py

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
Let's begin by importing all the necessary libraries.
2323
"""
2424

25+
"""shell
26+
pip install -q keras-rs
27+
"""
28+
2529
import os
2630

2731
os.environ["KERAS_BACKEND"] = "jax" # `"tensorflow"`/`"torch"`

examples/keras_rs/scann.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@
4444
also set the backend to JAX.
4545
"""
4646

47-
# ruff: noqa: E402
48-
4947
"""shell
48+
pip install -q keras-rs
5049
pip install -q scann
5150
"""
5251

examples/keras_rs/sequential_retrieval.py

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
the necessary libraries.
2222
"""
2323

24+
"""shell
25+
pip install -q keras-rs
26+
"""
27+
2428
import os
2529

2630
os.environ["KERAS_BACKEND"] = "jax" # `"tensorflow"`/`"torch"`

0 commit comments

Comments
 (0)