Last active
April 4, 2018 13:56
-
-
Save mohapatras/9f56f316b582e0a82826302e8af0692a to your computer and use it in GitHub Desktop.
Assign before doing any keras operation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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