Skip to content

Instantly share code, notes, and snippets.

@mohapatras
Last active April 4, 2018 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohapatras/9f56f316b582e0a82826302e8af0692a to your computer and use it in GitHub Desktop.
Save mohapatras/9f56f316b582e0a82826302e8af0692a to your computer and use it in GitHub Desktop.
Assign before doing any keras operation.
# keras example imports
from keras.models import load_model
## extra imports to set GPU options
import tensorflow as tf
from keras import backend as k
###################################
# TensorFlow wizardry
config = tf.ConfigProto()
# Don't pre-allocate memory; allocate as-needed
config.gpu_options.allow_growth = True
# Only allow a total of half the GPU memory to be allocated
config.gpu_options.per_process_gpu_memory_fraction = 0.5
# Create a session with the above options specified.
k.tensorflow_backend.set_session(tf.Session(config=config))
###################################
# returns a compiled model
# identical to the previous one
model = load_model('my_model.h5')
# TODO: classify all the things
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment