
    6bi,                         S r SSKrSSKJr  SSKJr  \R                  " 5       q\" S5      SS j5       r\" S5      SS j5       r	\" S	5      SS
 j5       r
g)z>Functions that save the model's config into different formats.    N)keras_export)serializationzkeras.models.model_from_configc                 P   [        U [        5      (       a  [        SU  S35      eSSKJn  [        [        S5      (       dC  UR                  R                  5         UR                  R                  R                  [        l
        [        R                  " U [        R                  USS9$ )a  Instantiates a TF-Keras model from its config.

Usage:
```
# for a Functional API model
tf.keras.Model().from_config(model.get_config())

# for a Sequential model
tf.keras.Sequential().from_config(model.get_config())
```

Args:
    config: Configuration dictionary.
    custom_objects: Optional dictionary mapping names
        (strings) to custom classes or functions to be
        considered during deserialization.

Returns:
    A TF-Keras model instance (uncompiled).

Raises:
    TypeError: if `config` is not a dictionary.
zG`model_from_config` expects a dictionary, not a list. Received: config=z8. Did you meant to use `Sequential.from_config(config)`?r   )layersALL_OBJECTSlayer)module_objectscustom_objectsprintable_module_name)
isinstancelist	TypeErrortf_keras.srcr   hasattrMODULE_OBJECTSr   populate_deserializable_objectsLOCALr   deserialize_keras_object)configr
   r   s      a/home/james-whalen/.local/lib/python3.13/site-packages/tf_keras/src/saving/legacy/model_config.pymodel_from_configr      s    2 &$  &x (00
 	

 $ >=11<<>%+%9%9%?%?%K%K"11%11%%	     zkeras.models.model_from_yamlc                     [        S5      e)a  Parses a yaml model configuration file and returns a model instance.

Note: Since TF 2.6, this method is no longer supported and will raise a
RuntimeError.

Args:
    yaml_string: YAML string or open file encoding a model configuration.
    custom_objects: Optional dictionary mapping names
        (strings) to custom classes or functions to be
        considered during deserialization.

Returns:
    A TF-Keras model instance (uncompiled).

Raises:
    RuntimeError: announces that the method poses a security risk
zMethod `model_from_yaml()` has been removed due to security risk of arbitrary code execution. Please use `Model.to_json()` and `model_from_json()` instead.)RuntimeError)yaml_stringr
   s     r   model_from_yamlr   J   s    & 	' r   zkeras.models.model_from_jsonc                     SSK Jn  U" XS9$ )a4  Parses a JSON model configuration string and returns a model instance.

Usage:

>>> model = tf.keras.Sequential([
...     tf.keras.layers.Dense(5, input_shape=(3,)),
...     tf.keras.layers.Softmax()])
>>> config = model.to_json()
>>> loaded_model = tf.keras.models.model_from_json(config)

Args:
    json_string: JSON string encoding a model configuration.
    custom_objects: Optional dictionary mapping names
        (strings) to custom classes or functions to be
        considered during deserialization.

Returns:
    A TF-Keras model instance (uncompiled).
r   )deserialize_from_json)r
   )tf_keras.src.layersr   )json_stringr
   r   s      r   model_from_jsonr!   d   s    * !LLr   )N)__doc__	threading tensorflow.python.util.tf_exportr   tf_keras.src.saving.legacyr   localr   r   r   r!    r   r   <module>r(      ss     E  9 4" ./+ 0+\ ,- .2 ,-M .Mr   