Skip to content

Commit cc31519

Browse files
committed
update 'Functional API' guide
keras-team/keras#19951
1 parent a965e04 commit cc31519

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

.tether/vignettes-src/functional_api.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ Train the model by passing lists of NumPy arrays of inputs and targets:
396396

397397
```python
398398
# Dummy input data
399-
title_data = np.random.randint(num_words, size=(1280, 10))
399+
title_data = np.random.randint(num_words, size=(1280, 12))
400400
body_data = np.random.randint(num_words, size=(1280, 100))
401401
tags_data = np.random.randint(2, size=(1280, num_tags)).astype("float32")
402402

vignettes-src/functional_api.Rmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ Train the model by passing lists of NumPy arrays of inputs and targets:
414414

415415
```{r}
416416
# Dummy input data
417-
title_data <- random_integer(c(1280, 10), 0, num_words)
417+
title_data <- random_integer(c(1280, 12), 0, num_words)
418418
body_data <- random_integer(c(1280, 100), 0, num_words)
419419
tags_data <- random_integer(c(1280, num_tags), 0, 2)
420420
@@ -614,9 +614,9 @@ custom_dense <- Layer(
614614
)
615615
self$b <- self$add_weight(
616616
shape = shape(self$units),
617-
initializer="random_normal",
617+
initializer="random_normal",
618618
trainable = TRUE
619-
)
619+
)
620620
},
621621
call = function(inputs) {
622622
op_matmul(inputs, self$w) + self$b
@@ -649,9 +649,9 @@ custom_dense <- Layer(
649649
)
650650
self$b <- self$add_weight(
651651
shape = shape(self$units),
652-
initializer="random_normal",
652+
initializer="random_normal",
653653
trainable = TRUE
654-
)
654+
)
655655
},
656656
657657
call = function(inputs) {
-16.6 KB
Binary file not shown.
-64.7 KB
Binary file not shown.
-119 KB
Binary file not shown.

vignettes/functional_api.Rmd

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,15 @@ history <- model |> fit(
210210
## Epoch 1/2
211211
## 750/750 - 2s - 2ms/step - accuracy: 0.8979 - loss: 0.3540 - val_accuracy: 0.9448 - val_loss: 0.1903
212212
## Epoch 2/2
213-
## 750/750 - 1s - 773us/step - accuracy: 0.9511 - loss: 0.1634 - val_accuracy: 0.9605 - val_loss: 0.1386
213+
## 750/750 - 1s - 785us/step - accuracy: 0.9511 - loss: 0.1634 - val_accuracy: 0.9605 - val_loss: 0.1386
214214
```
215215

216216
``` r
217217
test_scores <- model |> evaluate(x_test, y_test, verbose=2)
218218
```
219219

220220
```
221-
## 313/313 - 0s - 980us/step - accuracy: 0.9593 - loss: 0.1323
221+
## 313/313 - 0s - 1ms/step - accuracy: 0.9593 - loss: 0.1323
222222
```
223223

224224

@@ -625,7 +625,7 @@ Train the model by passing lists of NumPy arrays of inputs and targets:
625625

626626
``` r
627627
# Dummy input data
628-
title_data <- random_integer(c(1280, 10), 0, num_words)
628+
title_data <- random_integer(c(1280, 12), 0, num_words)
629629
body_data <- random_integer(c(1280, 100), 0, num_words)
630630
tags_data <- random_integer(c(1280, num_tags), 0, 2)
631631

@@ -643,9 +643,9 @@ model |> fit(
643643

644644
```
645645
## Epoch 1/2
646-
## 40/40 - 2s - 57ms/step - loss: 0.3948
646+
## 40/40 - 2s - 60ms/step - loss: 348.4560
647647
## Epoch 2/2
648-
## 40/40 - 0s - 5ms/step - loss: 0.1971
648+
## 40/40 - 0s - 6ms/step - loss: 255.0283
649649
```
650650

651651
When calling fit with a `Dataset` object, it should yield either a
@@ -776,7 +776,7 @@ model |> fit(
776776
```
777777

778778
```
779-
## 13/13 - 5s - 373ms/step - acc: 0.1238 - loss: 2.2995 - val_acc: 0.1300 - val_loss: 2.2957
779+
## 13/13 - 5s - 380ms/step - acc: 0.1213 - loss: 2.3001 - val_acc: 0.1250 - val_loss: 2.2895
780780
```
781781

782782
## Shared layers
@@ -890,9 +890,9 @@ custom_dense <- Layer(
890890
)
891891
self$b <- self$add_weight(
892892
shape = shape(self$units),
893-
initializer="random_normal",
893+
initializer="random_normal",
894894
trainable = TRUE
895-
)
895+
)
896896
},
897897
call = function(inputs) {
898898
op_matmul(inputs, self$w) + self$b
@@ -926,9 +926,9 @@ custom_dense <- Layer(
926926
)
927927
self$b <- self$add_weight(
928928
shape = shape(self$units),
929-
initializer="random_normal",
929+
initializer="random_normal",
930930
trainable = TRUE
931-
)
931+
)
932932
},
933933

934934
call = function(inputs) {

0 commit comments

Comments
 (0)