Created
April 13, 2016 17:14
-
-
Save isaacgerg/5912700d93ffb6784400c95dc65d73bf to your computer and use it in GitHub Desktop.
This file contains 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
import keras | |
from keras import backend as K | |
import keras.models | |
#--------------------------------------------------------------------------------------------------- | |
model = keras.models.Sequential() | |
model.add(keras.layers.Convolution2D(8, 5, 5, W_constraint = keras.constraints.maxnorm(), input_shape=(1, 100, 100))) | |
# Commenting out the next line reemoves the MissingInputError | |
model.add(keras.layers.Dropout(0.25)) | |
model.add(keras.layers.Flatten()) | |
model.add(keras.layers.Dense(2)) | |
for k in model.layers: | |
if type(k) is keras.layers.Dropout: | |
model.layers.remove(k) | |
print(model.layers) | |
input_img = model.layers[0].input | |
layer_output = model.layers[-1].output | |
from keras import backend as K | |
loss = K.mean(layer_output) | |
grads = K.gradients(loss, input_img)[0] | |
iterate = K.function([input_img], [loss, grads]) # Will blow up on this line. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment