
    BVh                     ,    d Z ddlmZ ddZddZddZy)z>Functions that save the model's config into different formats.    )
json_utilsNc                 X    t        | t              rt        d      ddlm}  || |      S )a-  Instantiates a 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 Keras model instance (uncompiled).

  Raises:
      TypeError: if `config` is not a dictionary.
  zn`model_from_config` expects a dictionary, not a list. Maybe you meant to use `Sequential.from_config(config)`?r   deserializecustom_objects)
isinstancelist	TypeErrortensorflow.python.keras.layersr   )configr   r   s      [/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/keras/saving/model_config.pymodel_from_configr      s2    0 
 8 9 9 9	VN	;;    c                     t        d      )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 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   5   s    $ 	%	 r   c                 L    t        j                  |       }ddlm}  |||      S )aM  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 Keras model instance (uncompiled).
  r   r   r   )r   decoder   r   )json_stringr   r   r   s       r   model_from_jsonr   N   s$    ( [)&8	VN	;;r   )N)__doc__*tensorflow.python.keras.saving.saved_modelr   r   r   r    r   r   <module>r      s     E A<@2<r   