Skip to content

Commit 2c83041

Browse files
authored
Merge pull request #1484 from rstudio/retether-3.7.0
Retether Keras 3.7.0
2 parents ea439e0 + 94b5857 commit 2c83041

File tree

1,377 files changed

+32094
-3526
lines changed

Some content is hidden

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

1,377 files changed

+32094
-3526
lines changed

.tether/man/Loss.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ class Loss(keras.src.saving.keras_saveable.KerasSaveable)
55
|
66
| Loss base class.
77
|
8+
| This is the class to subclass in order to create new custom losses.
9+
|
810
| Args:
911
| reduction: Type of reduction to apply to the loss. In almost all cases
10-
| this should be `"sum_over_batch_size"`.
11-
| Supported options are `"sum"`, `"sum_over_batch_size"` or `None`.
12+
| this should be `"sum_over_batch_size"`. Supported options are
13+
| `"sum"`, `"sum_over_batch_size"`, `"mean"`,
14+
| `"mean_with_sample_weight"` or `None`. `"sum"` sums the loss,
15+
| `"sum_over_batch_size"` and `"mean"` sum the loss and divide by the
16+
| sample size, and `"mean_with_sample_weight"` sums the loss and
17+
| divides by the sum of the sample weights. `"none"` and `None`
18+
| perform no aggregation. Defaults to `"sum_over_batch_size"`.
1219
| name: Optional name for the loss instance.
1320
| dtype: The dtype of the loss's computations. Defaults to `None`, which
1421
| means using `keras.backend.floatx()`. `keras.backend.floatx()` is a

.tether/man/activation_celu.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
__signature__
2+
keras.activations.celu(x, alpha=1.0)
3+
__doc__
4+
Continuously Differentiable Exponential Linear Unit.
5+
6+
The CeLU activation function is defined as:
7+
8+
`celu(x) = alpha * (exp(x / alpha) - 1) for x < 0`,`celu(x) = x for x >= 0`.
9+
10+
where `alpha` is a scaling parameter that controls the activation's shape.
11+
12+
Args:
13+
x: Input tensor.
14+
alpha: The α value for the CeLU formulation. Defaults to `1.0`.
15+
16+
Reference:
17+
18+
- [Barron, J. T., 2017](https://arxiv.org/abs/1704.07483)
19+

.tether/man/activation_glu.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
__signature__
2+
keras.activations.glu(x, axis=-1)
3+
__doc__
4+
Gated Linear Unit (GLU) activation function.
5+
6+
The GLU activation function is defined as:
7+
8+
`glu(x) = a * sigmoid(b)`,
9+
10+
where `x` is split into two equal parts `a` and `b` along the given axis.
11+
12+
Args:
13+
x: Input tensor.
14+
axis: The axis along which to split the input tensor. Defaults to `-1`.
15+
16+
Reference:
17+
18+
- [Dauphin et al., 2017](https://arxiv.org/abs/1612.08083)
19+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
__signature__
2+
keras.activations.hard_shrink(x, threshold=0.5)
3+
__doc__
4+
Hard Shrink activation function.
5+
6+
It is defined as:
7+
8+
`hard_shrink(x) = x` if `|x| > threshold`,
9+
`hard_shrink(x) = 0` otherwise.
10+
11+
Args:
12+
x: Input tensor.
13+
threshold: Threshold value. Defaults to 0.5.
14+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
__signature__
2+
keras.activations.hard_tanh(x)
3+
__doc__
4+
HardTanh activation function.
5+
6+
It is defined as:
7+
`hard_tanh(x) = -1 for x < -1`,
8+
`hard_tanh(x) = x for -1 <= x <= 1`,
9+
`hard_tanh(x) = 1 for x > 1`.
10+
11+
Args:
12+
x: Input tensor.
13+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
__signature__
2+
keras.activations.log_sigmoid(x)
3+
__doc__
4+
Logarithm of the sigmoid activation function.
5+
6+
It is defined as `f(x) = log(1 / (1 + exp(-x)))`.
7+
8+
Args:
9+
x: Input tensor.
10+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
__signature__
2+
keras.activations.soft_shrink(x, threshold=0.5)
3+
__doc__
4+
Soft Shrink activation function.
5+
6+
It is defined as:
7+
8+
`soft_shrink(x) = x - threshold` if `x > threshold`,
9+
`soft_shrink(x) = x + threshold` if `x < -threshold`,
10+
`soft_shrink(x) = 0` otherwise.
11+
12+
Args:
13+
x: Input tensor.
14+
threshold: Threshold value. Defaults to 0.5.
15+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
__signature__
2+
keras.activations.squareplus(x, b=4)
3+
__doc__
4+
Squareplus activation function.
5+
6+
The Squareplus activation function is defined as:
7+
8+
`f(x) = (x + sqrt(x^2 + b)) / 2`
9+
10+
Where `b` is a smoothness parameter.
11+
12+
Args:
13+
x: Input tensor.
14+
b: Smoothness parameter. Defaults to 4.
15+
16+
Reference:
17+
18+
- [Ramachandran et al., 2021](https://arxiv.org/abs/2112.11687)
19+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
__signature__
2+
keras.activations.tanh_shrink(x)
3+
__doc__
4+
Tanh shrink activation function.
5+
6+
It is defined as:
7+
8+
`f(x) = x - tanh(x)`.
9+
10+
Args:
11+
x: Input tensor.
12+

.tether/man/callback_backup_and_restore.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Help on class BackupAndRestore in module keras.src.callbacks.backup_and_restore:
22

33
class BackupAndRestore(keras.src.callbacks.callback.Callback)
4-
| BackupAndRestore(backup_dir, save_freq='epoch', delete_checkpoint=True)
4+
| BackupAndRestore(backup_dir, save_freq='epoch', double_checkpoint=False, delete_checkpoint=True)
55
|
66
| Callback to back up and restore the training state.
77
|
@@ -59,6 +59,12 @@ class BackupAndRestore(keras.src.callbacks.callback.Callback)
5959
| When set to an integer, the callback saves the checkpoint every
6060
| `save_freq` batches. Set `save_freq=False` only if using
6161
| preemption checkpointing (i.e. with `save_before_preemption=True`).
62+
| double_checkpoint: Boolean. If enabled, `BackupAndRestore` callback
63+
| will save 2 last training states (current and previous). After
64+
| interruption if current state can't be loaded due to IO error
65+
| (e.g. file corrupted) it will try to restore previous one. Such
66+
| behaviour will consume twice more space on disk, but increase fault
67+
| tolerance. Defaults to `False`.
6268
| delete_checkpoint: Boolean. This `BackupAndRestore`
6369
| callback works by saving a checkpoint to back up the training state.
6470
| If `delete_checkpoint=True`, the checkpoint will be deleted after
@@ -76,6 +82,7 @@ class BackupAndRestore(keras.src.callbacks.callback.Callback)
7682
| self,
7783
| backup_dir,
7884
| save_freq='epoch',
85+
| double_checkpoint=False,
7986
| delete_checkpoint=True
8087
| )
8188
| Initialize self. See help(type(self)) for accurate signature.
@@ -116,7 +123,13 @@ class BackupAndRestore(keras.src.callbacks.callback.Callback)
116123
| logs: Dict. Aggregated metric results up until this batch.
117124
|
118125
| on_train_begin(self, logs=None)
119-
| Get training state from temporary file and restore it.
126+
| Called at the beginning of training.
127+
|
128+
| Subclasses should override for any actions to run.
129+
|
130+
| Args:
131+
| logs: Dict. Currently no data is passed to this argument for this
132+
| method but that may change in the future.
120133
|
121134
| on_train_end(self, logs=None)
122135
| Called at the end of training.

0 commit comments

Comments
 (0)