Skip to content

Commit

Permalink
Merge pull request #1447 from rstudio/retether-3.3.3
Browse files Browse the repository at this point in the history
Retether to Keras 3.3.3
  • Loading branch information
t-kalinowski authored May 17, 2024
2 parents b40657b + e5be5be commit 1b4f1cd
Show file tree
Hide file tree
Showing 663 changed files with 3,188 additions and 631 deletions.
2 changes: 1 addition & 1 deletion .tether/man/Constraint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Constraint(builtins.object)
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_config(config) from builtins.type
| from_config(config)
| Instantiates a weight constraint from a configuration dictionary.
|
| Example:
Expand Down
1 change: 1 addition & 0 deletions .tether/man/InputLayer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class InputLayer(keras.src.layers.layer.Layer)
| tensorflow.python.trackable.autotrackable.AutoTrackable
| tensorflow.python.trackable.base.Trackable
| keras.src.ops.operation.Operation
| keras.src.saving.keras_saveable.KerasSaveable
| builtins.object
|
| Methods defined here:
Expand Down
3 changes: 2 additions & 1 deletion .tether/man/Layer.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Help on class Layer in module keras.src.layers.layer:

class Layer(keras.src.backend.tensorflow.layer.TFLayer, keras.src.ops.operation.Operation)
class Layer(keras.src.backend.tensorflow.layer.TFLayer, keras.src.ops.operation.Operation, keras.src.saving.keras_saveable.KerasSaveable)
| Layer(*args, **kwargs)
|
| This is the class from which all layers inherit.
Expand Down Expand Up @@ -161,6 +161,7 @@ class Layer(keras.src.backend.tensorflow.layer.TFLayer, keras.src.ops.operation.
| tensorflow.python.trackable.autotrackable.AutoTrackable
| tensorflow.python.trackable.base.Trackable
| keras.src.ops.operation.Operation
| keras.src.saving.keras_saveable.KerasSaveable
| builtins.object
|
| Methods defined here:
Expand Down
2 changes: 1 addition & 1 deletion .tether/man/LearningRateSchedule.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class LearningRateSchedule(builtins.object)
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_config(config) from builtins.type
| from_config(config)
| Instantiates a `LearningRateSchedule` from its config.
|
| Args:
Expand Down
23 changes: 8 additions & 15 deletions .tether/man/Loss.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
Help on class Loss in module keras.src.losses.loss:

class Loss(builtins.object)
| Loss(
| name=None,
| reduction='sum_over_batch_size',
| dtype=None
| )
class Loss(keras.src.saving.keras_saveable.KerasSaveable)
| Loss(name=None, reduction='sum_over_batch_size', dtype=None)
|
| Loss base class.
|
Expand All @@ -22,6 +18,11 @@ class Loss(builtins.object)
| return ops.mean(ops.square(y_pred - y_true), axis=-1)
| ```
|
| Method resolution order:
| Loss
| keras.src.saving.keras_saveable.KerasSaveable
| builtins.object
|
| Methods defined here:
|
| __call__(
Expand Down Expand Up @@ -51,14 +52,6 @@ class Loss(builtins.object)
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_config(config) from builtins.type
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
| from_config(config)
|
| __weakref__
| list of weak references to the object

17 changes: 7 additions & 10 deletions .tether/man/Metric.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Help on class Metric in module keras.src.metrics.metric:

class Metric(builtins.object)
class Metric(keras.src.saving.keras_saveable.KerasSaveable)
| Metric(dtype=None, name=None)
|
| Encapsulates metric logic and state.
Expand Down Expand Up @@ -77,6 +77,11 @@ class Metric(builtins.object)
| return self.true_positives
| ```
|
| Method resolution order:
| Metric
| keras.src.saving.keras_saveable.KerasSaveable
| builtins.object
|
| Methods defined here:
|
| __call__(
Expand Down Expand Up @@ -159,7 +164,7 @@ class Metric(builtins.object)
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_config(config) from builtins.type
| from_config(config)
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
Expand All @@ -168,12 +173,4 @@ class Metric(builtins.object)
|
| variables
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object

2 changes: 1 addition & 1 deletion .tether/man/callback_early_stopping.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class EarlyStopping(keras.src.callbacks.callback.Callback)
| improvement is expected and thus training will not be stopped.
| Defaults to `0`.
|
|
| Example:
|
| >>> callback = keras.callbacks.EarlyStopping(monitor='loss',
Expand Down Expand Up @@ -118,3 +117,4 @@ class EarlyStopping(keras.src.callbacks.callback.Callback)
| `on_epoch_end()` is passed to this argument for this method but
| that may change in the future.
|

123 changes: 123 additions & 0 deletions .tether/man/clone_model.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
__signature__
keras.models.clone_model(
model,
input_tensors=None,
clone_function=None,
call_function=None,
recursive=False,
**kwargs
)
__doc__
Clone a Functional or Sequential `Model` instance.

Model cloning is similar to calling a model on new inputs,
except that it creates new layers (and thus new weights) instead
of sharing the weights of the existing layers.

Note that
`clone_model` will not preserve the uniqueness of shared objects within the
model (e.g. a single variable attached to two distinct layers will be
restored as two separate variables).

Args:
model: Instance of `Model`
(could be a Functional model or a Sequential model).
input_tensors: optional list of input tensors or InputLayer objects
to build the model upon. If not provided,
new `Input` objects will be created.
clone_function: Callable with signature `fn(layer)`
to be used to clone each layer in the target
model (except `Input` instances). It takes as argument the
layer instance to be cloned, and returns the corresponding layer
instance to be used in the model copy. If unspecified, this callable
defaults to the following serialization/deserialization function:
`lambda layer: layer.__class__.from_config(layer.get_config())`.
By passing a custom callable, you can customize your copy of the
model, e.g. by wrapping certain layers of interest (you might want
to replace all `LSTM` instances with equivalent
`Bidirectional(LSTM(...))` instances, for example).
Defaults to `None`.
call_function: Callable with signature
`fn(layer, *args, **kwargs)` to be used to call each
cloned layer and a set of inputs. It takes the layer instance,
the call arguments and keyword arguments, and returns the
call outputs. If unspecified, this callable defaults to
the regular `__call__()` method:
`def fn(layer, *args, **kwargs): return layer(*args, **kwargs)`.
By passing a custom callable, you can insert new layers before or
after a given layer. Note: this argument can only be used with
Functional models.
recursive: Boolean. Whether to recursively clone any Sequential
or Functional models encountered in the original
Sequential/Functional model. If `False`,
then inner models are cloned by calling `clone_function()`.
If `True`, then inner models are cloned by calling `clone_model()`
with the same `clone_function`, `call_function`, and `recursive`
arguments. Note that in this case, `call_function`
will not be propagated to any Sequential model
(since it is not applicable to Sequential models).

Returns:
An instance of `Model` reproducing the behavior
of the original model, on top of new inputs tensors,
using newly instantiated weights. The cloned model may behave
differently from the original model if a custom `clone_function`
or `call_function` modifies a layer or layer call.

Example:

```python
# Create a test Sequential model.
model = keras.Sequential([
keras.layers.Input(shape=(728,)),
keras.layers.Dense(32, activation='relu'),
keras.layers.Dense(1, activation='sigmoid'),
])
# Create a copy of the test model (with freshly initialized weights).
new_model = clone_model(model)
```

Using a `clone_function` to make a model deterministic by setting the
random seed everywhere:

```python
def clone_function(layer):
config = layer.get_config()
if "seed" in config:
config["seed"] = 1337
return layer.__class__.from_config(config)

new_model = clone_model(model)
```

Using a `call_function` to add a `Dropout` layer after each `Dense` layer
(without recreating new layers):

```python
def call_function(layer, *args, **kwargs):
out = layer(*args, **kwargs)
if isinstance(layer, keras.layers.Dense):
out = keras.layers.Dropout(0.5)(out)
return out

new_model = clone_model(
model,
clone_function=lambda x: x, # Reuse the same layers.
call_function=call_function,
)
```

Note that subclassed models cannot be cloned by default,
since their internal layer structure is not known.
To achieve equivalent functionality
as `clone_model` in the case of a subclassed model, simply make sure
that the model class implements `get_config()`
(and optionally `from_config()`), and call:

```python
new_model = model.__class__.from_config(model.get_config())
```

In the case of a subclassed model, you cannot using a custom
`clone_function`.

3 changes: 2 additions & 1 deletion .tether/man/initializer_constant.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Constant(keras.src.initializers.initializer.Initializer)
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_config(config) from builtins.type
| from_config(config)
| Instantiates an initializer from a configuration dictionary.
|
| Example:
Expand All @@ -69,3 +69,4 @@ class Constant(keras.src.initializers.initializer.Initializer)
| Returns:
| An `Initializer` instance.
|

2 changes: 1 addition & 1 deletion .tether/man/keras.losses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ CosineSimilarity(
name='cosine_similarity'
)
ctc(y_true, y_pred)
CTC(reduction='sum_over_batch_size', name='sparse_categorical_crossentropy')
CTC(reduction='sum_over_batch_size', name='ctc')
deserialize(name, custom_objects=None)
dice(y_true, y_pred)
Dice(reduction='sum_over_batch_size', name='dice')
Expand Down
5 changes: 4 additions & 1 deletion .tether/man/keras.models.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
clone_model(
model,
input_tensors=None,
clone_function=None
clone_function=None,
call_function=None,
recursive=False,
**kwargs
)
load_model(
filepath,
Expand Down
7 changes: 6 additions & 1 deletion .tether/man/keras.ops.nn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ conv_transpose(
ctc_decode(
inputs,
sequence_lengths,
strategy,
strategy='greedy',
beam_width=100,
top_paths=1,
merge_repeated=True,
Expand Down Expand Up @@ -107,6 +107,11 @@ one_hot(
dtype=None,
sparse=False
)
psnr(
x1,
x2,
max_val
)
relu(x)
relu6(x)
selu(x)
Expand Down
1 change: 1 addition & 0 deletions .tether/man/keras.ops.numpy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ sign(x)
sin(x)
sinh(x)
size(x)
slogdet(x)
sort(x, axis=-1)
split(
x,
Expand Down
8 changes: 7 additions & 1 deletion .tether/man/keras.ops.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ cross(
ctc_decode(
inputs,
sequence_lengths,
strategy,
strategy='greedy',
beam_width=100,
top_paths=1,
merge_repeated=True,
Expand Down Expand Up @@ -412,6 +412,11 @@ prod(
keepdims=False,
dtype=None
)
psnr(
x1,
x2,
max_val
)
qr(x, mode='reduced')
quantile(
x,
Expand Down Expand Up @@ -493,6 +498,7 @@ slice_update(
start_indices,
updates
)
slogdet(x)
softmax(x, axis=-1)
softplus(x)
softsign(x)
Expand Down
10 changes: 2 additions & 8 deletions .tether/man/keras_model.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class Model(keras.src.backend.tensorflow.trainer.TensorFlowTrainer, keras.src.tr
| tensorflow.python.trackable.autotrackable.AutoTrackable
| tensorflow.python.trackable.base.Trackable
| keras.src.ops.operation.Operation
| keras.src.saving.keras_saveable.KerasSaveable
| builtins.object
|
| Methods defined here:
Expand All @@ -127,13 +128,6 @@ class Model(keras.src.backend.tensorflow.trainer.TensorFlowTrainer, keras.src.tr
| )
| Initialize self. See help(type(self)) for accurate signature.
|
| __reduce__(self)
| __reduce__ is used to customize the behavior of `pickle.pickle()`.
|
| The method returns a tuple of two elements: a function, and a list of
| arguments to pass to that function. In this case we just leverage the
| keras saving library.
|
| build_from_config(self, config)
| Builds the layer's states with the supplied config dict.
|
Expand Down Expand Up @@ -360,7 +354,7 @@ class Model(keras.src.backend.tensorflow.trainer.TensorFlowTrainer, keras.src.tr
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_config(config, custom_objects=None) from builtins.type
| from_config(config, custom_objects=None)
| Creates a layer from its config.
|
| This method is the reverse of `get_config`,
Expand Down
Loading

0 comments on commit 1b4f1cd

Please sign in to comment.