Skip to content

Commit

Permalink
Add script to automate Keras release.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 512325363
  • Loading branch information
fchollet authored and tensorflower-gardener committed Feb 25, 2023
1 parent 09c2eaa commit 2dcab06
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
29 changes: 14 additions & 15 deletions keras/benchmarks/model_memory_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,23 @@
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"))
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))

model.compile("sgd", "mse")
# Warm up the model with one epoch.
model.fit(x_train, y_train, batch_size=512, epochs=3)
# 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(_):
# Add the model for memory profile.
models = {
"lstm": _imdb_lstm_model,
Expand Down
8 changes: 4 additions & 4 deletions pip_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
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):
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 2dcab06

Please sign in to comment.