Skip to content

Commit bdb04bb

Browse files
committed
Merge branch 'master' of github.com:keras-team/keras-io
2 parents 1d654e8 + 67408a4 commit bdb04bb

File tree

11 files changed

+88
-103
lines changed

11 files changed

+88
-103
lines changed

examples/audio/md/stft.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ plt.show()
605605

606606

607607

608-
![png](https://github.com/mostafa-mahmoud/keras-io/blob/master/examples/audio/img/stft/raw_audio.png)
608+
![png](https://github.com/keras-team/keras-io/blob/master/examples/audio/img/stft/raw_audio.png)
609609

610610

611611

@@ -618,7 +618,7 @@ plot_single_spectrogram(sample_wav_data)
618618

619619

620620

621-
![png](https://github.com/mostafa-mahmoud/keras-io/blob/master/examples/audio/img/stft/spectrogram.png)
621+
![png](https://github.com/keras-team/keras-io/blob/master/examples/audio/img/stft/spectrogram.png)
622622

623623

624624

@@ -631,7 +631,7 @@ plot_multi_bandwidth_spectrogram(sample_wav_data)
631631

632632

633633

634-
![png](https://github.com/mostafa-mahmoud/keras-io/blob/master/examples/audio/img/stft/multiband_spectrogram.png)
634+
![png](https://github.com/keras-team/keras-io/blob/master/examples/audio/img/stft/multiband_spectrogram.png)
635635

636636

637637

@@ -643,9 +643,7 @@ def read_dataset(df, folds):
643643
msk = df["fold"].isin(folds)
644644
filenames = df["filename"][msk]
645645
targets = df["target"][msk].values
646-
waves = np.array(
647-
[read_wav_file(fil) for fil in filenames], dtype=np.float32
648-
)
646+
waves = np.array([read_wav_file(fil) for fil in filenames], dtype=np.float32)
649647
return waves, targets
650648
```
651649

@@ -1790,7 +1788,7 @@ plt.show()
17901788

17911789

17921790

1793-
![png](https://github.com/mostafa-mahmoud/keras-io/blob/master/examples/audio/img/stft/training.png)
1791+
![png](https://github.com/keras-team/keras-io/blob/master/examples/audio/img/stft/training.png)
17941792

17951793

17961794

@@ -1802,9 +1800,7 @@ Running the models on the test set.
18021800

18031801
```python
18041802
_, test_acc = model1d.evaluate(test_x, test_y)
1805-
print(
1806-
f"1D model wit non-trainable STFT -> Test Accuracy: {test_acc * 100:.2f}%"
1807-
)
1803+
print(f"1D model wit non-trainable STFT -> Test Accuracy: {test_acc * 100:.2f}%")
18081804
```
18091805

18101806
3/3 ━━━━━━━━━━━━━━━━━━━━ 3s 307ms/step - accuracy: 0.8148 - loss: 0.6244

examples/keras_recipes/ipynb/reproducibility_recipes.ipynb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,13 @@
252252
" )\n",
253253
"\n",
254254
" model.compile(\n",
255-
" optimizer=\"adam\", loss=\"sparse_categorical_crossentropy\", metrics=[\"accuracy\"]\n",
255+
" optimizer=\"adam\",\n",
256+
" loss=\"sparse_categorical_crossentropy\",\n",
257+
" metrics=[\"accuracy\"],\n",
258+
" jit_compile=False,\n",
256259
" )\n",
260+
" # jit_compile's default value is \"auto\" which will cause some problems in some\n",
261+
" # ops, therefore it's set to False.\n",
257262
"\n",
258263
" # model.fit has a `shuffle` parameter which has a default value of `True`.\n",
259264
" # If you are using array-like objects, this will shuffle the data before\n",

examples/keras_recipes/md/reproducibility_recipes.md

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,89 +87,89 @@ for initializer in initializers_list:
8787
<div class="k-default-codeblock">
8888
```
8989
Running <class 'keras.src.initializers.random_initializers.RandomNormal'>
90-
Iteration --> 0 // Result --> 0.05609520897269249
91-
Iteration --> 1 // Result --> 0.05609520897269249
90+
Iteration --> 0 // Result --> 0.000790853810030967
91+
Iteration --> 1 // Result --> 0.000790853810030967
9292
```
9393
</div>
9494

9595

9696
<div class="k-default-codeblock">
9797
```
9898
Running <class 'keras.src.initializers.random_initializers.RandomUniform'>
99-
Iteration --> 0 // Result --> 0.03690483793616295
100-
Iteration --> 1 // Result --> 0.03690483793616295
99+
Iteration --> 0 // Result --> -0.02175668440759182
100+
Iteration --> 1 // Result --> -0.02175668440759182
101101
```
102102
</div>
103103

104104

105105
<div class="k-default-codeblock">
106106
```
107107
Running <class 'keras.src.initializers.random_initializers.TruncatedNormal'>
108-
Iteration --> 0 // Result --> 0.05230803042650223
109-
Iteration --> 1 // Result --> 0.05230803042650223
108+
Iteration --> 0 // Result --> 0.000790853810030967
109+
Iteration --> 1 // Result --> 0.000790853810030967
110110
```
111111
</div>
112112

113113

114114
<div class="k-default-codeblock">
115115
```
116116
Running <class 'keras.src.initializers.random_initializers.VarianceScaling'>
117-
Iteration --> 0 // Result --> 1.1893247365951538
118-
Iteration --> 1 // Result --> 1.1893247365951538
117+
Iteration --> 0 // Result --> 0.017981600016355515
118+
Iteration --> 1 // Result --> 0.017981600016355515
119119
```
120120
</div>
121121

122122

123123
<div class="k-default-codeblock">
124124
```
125125
Running <class 'keras.src.initializers.random_initializers.GlorotNormal'>
126-
Iteration --> 0 // Result --> 1.1893247365951538
127-
Iteration --> 1 // Result --> 1.1893247365951538
126+
Iteration --> 0 // Result --> 0.017981600016355515
127+
Iteration --> 1 // Result --> 0.017981600016355515
128128
```
129129
</div>
130130

131131

132132
<div class="k-default-codeblock">
133133
```
134134
Running <class 'keras.src.initializers.random_initializers.GlorotUniform'>
135-
Iteration --> 0 // Result --> 1.2784210443496704
136-
Iteration --> 1 // Result --> 1.2784210443496704
135+
Iteration --> 0 // Result --> -0.7536736726760864
136+
Iteration --> 1 // Result --> -0.7536736726760864
137137
```
138138
</div>
139139

140140

141141
<div class="k-default-codeblock">
142142
```
143143
Running <class 'keras.src.initializers.random_initializers.HeNormal'>
144-
Iteration --> 0 // Result --> 1.6819592714309692
145-
Iteration --> 1 // Result --> 1.6819592714309692
144+
Iteration --> 0 // Result --> 0.025429822504520416
145+
Iteration --> 1 // Result --> 0.025429822504520416
146146
```
147147
</div>
148148

149149

150150
<div class="k-default-codeblock">
151151
```
152152
Running <class 'keras.src.initializers.random_initializers.HeUniform'>
153-
Iteration --> 0 // Result --> 1.8079603910446167
154-
Iteration --> 1 // Result --> 1.8079603910446167
153+
Iteration --> 0 // Result --> -1.065855622291565
154+
Iteration --> 1 // Result --> -1.065855622291565
155155
```
156156
</div>
157157

158158

159159
<div class="k-default-codeblock">
160160
```
161161
Running <class 'keras.src.initializers.random_initializers.LecunNormal'>
162-
Iteration --> 0 // Result --> 1.1893247365951538
163-
Iteration --> 1 // Result --> 1.1893247365951538
162+
Iteration --> 0 // Result --> 0.017981600016355515
163+
Iteration --> 1 // Result --> 0.017981600016355515
164164
```
165165
</div>
166166

167167

168168
<div class="k-default-codeblock">
169169
```
170170
Running <class 'keras.src.initializers.random_initializers.LecunUniform'>
171-
Iteration --> 0 // Result --> 1.2784210443496704
172-
Iteration --> 1 // Result --> 1.2784210443496704
171+
Iteration --> 0 // Result --> -0.7536736726760864
172+
Iteration --> 1 // Result --> -0.7536736726760864
173173
```
174174
</div>
175175

@@ -273,8 +273,13 @@ def train_model(train_data: tf.data.Dataset, test_data: tf.data.Dataset) -> dict
273273
)
274274

275275
model.compile(
276-
optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"]
276+
optimizer="adam",
277+
loss="sparse_categorical_crossentropy",
278+
metrics=["accuracy"],
279+
jit_compile=False,
277280
)
281+
# jit_compile's default value is "auto" which will cause some problems in some
282+
# ops, therefore it's set to False.
278283

279284
# model.fit has a `shuffle` parameter which has a default value of `True`.
280285
# If you are using array-like objects, this will shuffle the data before
@@ -298,6 +303,13 @@ train_ds = tf.data.Dataset.from_tensor_slices((train_images, train_labels))
298303
test_ds = tf.data.Dataset.from_tensor_slices((test_images, test_labels))
299304
```
300305

306+
<div class="k-default-codeblock">
307+
```
308+
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz
309+
11490434/11490434 ━━━━━━━━━━━━━━━━━━━━ 0s 0us/step
310+
311+
```
312+
</div>
301313
Remember we called `tf.config.experimental.enable_op_determinism()` at the
302314
beginning of the function. This makes the `tf.data` operations deterministic.
303315
However, making `tf.data` operations deterministic comes with a performance
@@ -375,11 +387,11 @@ history = train_model(train_data, test_data)
375387
<div class="k-default-codeblock">
376388
```
377389
Epoch 1/2
378-
938/938 ━━━━━━━━━━━━━━━━━━━━ 26s 27ms/step - accuracy: 0.5418 - loss: 1.2867 - val_accuracy: 0.9291 - val_loss: 0.2303
390+
938/938 ━━━━━━━━━━━━━━━━━━━━ 73s 73ms/step - accuracy: 0.5726 - loss: 1.2175 - val_accuracy: 0.9401 - val_loss: 0.1924
379391
Epoch 2/2
380-
938/938 ━━━━━━━━━━━━━━━━━━━━ 25s 26ms/step - accuracy: 0.9075 - loss: 0.2983 - val_accuracy: 0.9583 - val_loss: 0.1343
381-
157/157 ━━━━━━━━━━━━━━━━━━━━ 1s 4ms/step - accuracy: 0.9512 - loss: 0.1559
382-
Model accuracy on test data: 95.83%
392+
938/938 ━━━━━━━━━━━━━━━━━━━━ 89s 81ms/step - accuracy: 0.9105 - loss: 0.2885 - val_accuracy: 0.9630 - val_loss: 0.1131
393+
157/157 ━━━━━━━━━━━━━━━━━━━━ 3s 17ms/step - accuracy: 0.9553 - loss: 0.1353
394+
Model accuracy on test data: 96.30%
383395
384396
```
385397
</div>

examples/keras_recipes/reproducibility_recipes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,13 @@ def train_model(train_data: tf.data.Dataset, test_data: tf.data.Dataset) -> dict
151151
)
152152

153153
model.compile(
154-
optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"]
154+
optimizer="adam",
155+
loss="sparse_categorical_crossentropy",
156+
metrics=["accuracy"],
157+
jit_compile=False,
155158
)
159+
# jit_compile's default value is "auto" which will cause some problems in some
160+
# ops, therefore it's set to False.
156161

157162
# model.fit has a `shuffle` parameter which has a default value of `True`.
158163
# If you are using array-like objects, this will shuffle the data before
1.13 MB
Loading
22.3 KB
Loading

guides/ipynb/keras_hub/stable_diffusion_3_in_keras_hub.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
},
4545
"outputs": [],
4646
"source": [
47-
"!!pip install -Uq keras\n",
48-
"!!pip install -Uq git+https://github.com/keras-team/keras-hub.git\n",
49-
"!!wget --user-agent=\"User-Agent: Mozilla/5.0\" -O mountain_dog.png https://i.imgur.com/3AHYG9Z.png\n",
50-
"!!wget --user-agent=\"User-Agent: Mozilla/5.0\" -O mountain_dog_mask.png https://i.imgur.com/n3Prpj6.png"
47+
"!pip install -Uq keras\n",
48+
"!pip install -Uq git+https://github.com/keras-team/keras-hub.git\n",
49+
"!wget -O mountain_dog.png https://raw.githubusercontent.com/keras-team/keras-io/master/guides/img/stable_diffusion_3_in_keras_hub/mountain_dog.png\n",
50+
"!wget -O mountain_dog_mask.png https://raw.githubusercontent.com/keras-team/keras-io/master/guides/img/stable_diffusion_3_in_keras_hub/mountain_dog_mask.png"
5151
]
5252
},
5353
{

guides/keras_hub/stable_diffusion_3_in_keras_hub.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"""shell
2828
!pip install -Uq keras
2929
!pip install -Uq git+https://github.com/keras-team/keras-hub.git
30-
!wget --user-agent="User-Agent: Mozilla/5.0" -O mountain_dog.png https://i.imgur.com/3AHYG9Z.png
31-
!wget --user-agent="User-Agent: Mozilla/5.0" -O mountain_dog_mask.png https://i.imgur.com/n3Prpj6.png
30+
!wget -O mountain_dog.png https://raw.githubusercontent.com/keras-team/keras-io/master/guides/img/stable_diffusion_3_in_keras_hub/mountain_dog.png
31+
!wget -O mountain_dog_mask.png https://raw.githubusercontent.com/keras-team/keras-io/master/guides/img/stable_diffusion_3_in_keras_hub/mountain_dog_mask.png
3232
"""
3333

3434
import os

guides/md/keras_hub/segment_anything_in_keras_hub.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ plt.show()
240240

241241

242242

243-
![png](/content/keras-io/guides/img/segment_anything_in_keras_hub/segment_anything_in_keras_hub_11_0.png)
243+
![png](/img/guides/segment_anything_in_keras_hub/segment_anything_in_keras_hub_11_0.png)
244244

245245

246246

@@ -262,7 +262,7 @@ plt.show()
262262

263263

264264

265-
![png](/content/keras-io/guides/img/segment_anything_in_keras_hub/segment_anything_in_keras_hub_13_0.png)
265+
![png](/img/guides/segment_anything_in_keras_hub/segment_anything_in_keras_hub_13_0.png)
266266

267267

268268

@@ -326,7 +326,7 @@ plt.show()
326326

327327

328328

329-
![png](/content/keras-io/guides/img/segment_anything_in_keras_hub/segment_anything_in_keras_hub_17_0.png)
329+
![png](/img/guides/segment_anything_in_keras_hub/segment_anything_in_keras_hub_17_0.png)
330330

331331

332332

@@ -354,7 +354,7 @@ plt.show()
354354

355355

356356

357-
![png](/content/keras-io/guides/img/segment_anything_in_keras_hub/segment_anything_in_keras_hub_20_0.png)
357+
![png](/img/guides/segment_anything_in_keras_hub/segment_anything_in_keras_hub_20_0.png)
358358

359359

360360

@@ -395,7 +395,7 @@ plt.show()
395395
```
396396
</div>
397397

398-
![png](/content/keras-io/guides/img/segment_anything_in_keras_hub/segment_anything_in_keras_hub_23_1.png)
398+
![png](/img/guides/segment_anything_in_keras_hub/segment_anything_in_keras_hub_23_1.png)
399399

400400

401401

@@ -442,7 +442,7 @@ plt.show()
442442
```
443443
</div>
444444

445-
![png](/content/keras-io/guides/img/segment_anything_in_keras_hub/segment_anything_in_keras_hub_25_1.png)
445+
![png](/img/guides/segment_anything_in_keras_hub/segment_anything_in_keras_hub_25_1.png)
446446

447447

448448

@@ -625,7 +625,7 @@ WARNING:matplotlib.image:Clipping input data to the valid range for imshow with
625625
```
626626
</div>
627627

628-
![png](/content/keras-io/guides/img/segment_anything_in_keras_hub/segment_anything_in_keras_hub_31_2.png)
628+
![png](/img/guides/segment_anything_in_keras_hub/segment_anything_in_keras_hub_31_2.png)
629629

630630

631631

@@ -690,7 +690,7 @@ WARNING:matplotlib.image:Clipping input data to the valid range for imshow with
690690
```
691691
</div>
692692

693-
![png](/content/keras-io/guides/img/segment_anything_in_keras_hub/segment_anything_in_keras_hub_35_1.png)
693+
![png](/img/guides/segment_anything_in_keras_hub/segment_anything_in_keras_hub_35_1.png)
694694

695695

696696

0 commit comments

Comments
 (0)