Add script to automate Keras release.

PiperOrigin-RevId: 512325363
This commit is contained in:
Francois Chollet 2023-02-25 13:00:21 -08:00 committed by TensorFlower Gardener
parent 09c2eaaf26
commit 2dcab061e2
2 changed files with 20 additions and 21 deletions

@ -37,24 +37,23 @@ FLAGS = flags.FLAGS
flags.DEFINE_string("model", None, "The model to run memory profiler.")
@memory_profiler.profile
def _imdb_lstm_model():
"""LSTM model."""
x_train = np.random.randint(0, 1999, size=(2500, 100))
y_train = np.random.random((2500, 1))
# IMDB LSTM model.
model = keras.Sequential()
model.add(keras.layers.Embedding(20000, 128))
model.add(keras.layers.LSTM(128, dropout=0.2, recurrent_dropout=0.2))
model.add(keras.layers.Dense(1, activation="sigmoid"))
model.compile("sgd", "mse")
# Warm up the model with one epoch.
model.fit(x_train, y_train, batch_size=512, epochs=3)
def main(_):
@memory_profiler.profile
def _imdb_lstm_model():
"""LSTM model."""
x_train = np.random.randint(0, 1999, size=(2500, 100))
y_train = np.random.random((2500, 1))
# IMDB LSTM model.
model = keras.Sequential()
model.add(keras.layers.Embedding(20000, 128))
model.add(keras.layers.LSTM(128, dropout=0.2, recurrent_dropout=0.2))
model.add(keras.layers.Dense(1, activation="sigmoid"))
model.compile("sgd", "mse")
# Warm up the model with one epoch.
model.fit(x_train, y_train, batch_size=512, epochs=3)
# Add the model for memory profile.
models = {
"lstm": _imdb_lstm_model,

@ -54,7 +54,7 @@ TMP_TEST_DIRNAME = "keras_test"
VERBOSE = True
INIT_FILE_HEADER = """AUTOGENERATED. DO NOT EDIT."""
# These are symbols that have export issues and that we skip for now.
SYMBOLS_TO_SKIP = []
SYMBOLS_TO_SKIP = ["layer_test"]
def copy_keras_codebase(source_dir, target_dir):
@ -235,11 +235,11 @@ def generate_keras_api_files(package_directory, src_directory):
root_offset=["api", "_v1", "keras"],
)
# Add missing __init__ files in api dirs.
with open(os.path.join(package_directory, "api", "__init__.py"), "w") as f:
with open(os.path.join(package_directory, "api", "__init__.py"), "w"):
pass
with open(os.path.join(v1_path, "__init__.py"), "w") as f:
with open(os.path.join(v1_path, "__init__.py"), "w"):
pass
with open(os.path.join(v2_path, "__init__.py"), "w") as f:
with open(os.path.join(v2_path, "__init__.py"), "w"):
pass