o
    i e                     @   s   d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ	 zddl
Z
W n ey/   dZ
Y nw ejZeddd dd	 Zed
krQedg e
rSee dS dS dS )zMemory profile on Keras model.

To add a new model for memory profile:
1. Create the model.
2. Decorate it with `@memory_profiler.profile`.
3. Add the model function to the dict `models`.
    N)app)flags)loggingmodelz!The model to run memory profiler.c                 C   sP   t jdd }d|i}tj|v r!tdtj |tj }|  d S td d S )Nc                  S   s   t jjdddd} t jd}t }|tjdd |tjjdddd	 |tjj	d
dd |
dd |j| |ddd dS )zLSTM model.r   i  )	  d   )size)r      i N     g?)dropoutrecurrent_dropoutr	   sigmoid)
activationsgdmsei      )
batch_sizeepochsN)nprandomrandintkeras
Sequentialaddlayers	EmbeddingLSTMDensecompilefit)x_trainy_trainr    r"   X/var/www/myenv/lib/python3.10/site-packages/keras/src/benchmarks/model_memory_profile.py_imdb_lstm_model)   s   zmain.<locals>._imdb_lstm_modellstmzRun memory profile on %s.z7The model does not exist. Please verify the model name.)memory_profilerprofileFLAGSr   r   info)_r$   models	run_modelr"   r"   r#   main(   s   



r-   __main__)__doc__numpyr   abslr   r   r   	keras.srcsrcr   r&   ImportErrorr(   DEFINE_stringr-   __name__mark_flags_as_requiredrunr"   r"   r"   r#   <module>   s(   