Skip to content

Commit

Permalink
Update get_feature_map.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wepe committed Jun 6, 2016
1 parent 899999a commit 44bf38d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions DeepLearning Tutorials/dive_into_keras/get_feature_map.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#coding=utf-8

"""
Author:wepon
Code:https://github.com/wepe
File: get_feature_map.py
1. visualize feature map of Convolution Layer, Fully Connected layer
2. rewrite the code so you can treat CNN as feature extractor, see file: cnn-svm.py
--
2016.06.06更新:
keras的API已经发生变化,现在可视化特征图可以直接调用接口,具体请参考:http://keras.io/visualization/
"""
from __future__ import print_function
import cPickle,theano
Expand All @@ -16,10 +24,10 @@
model = cPickle.load(open("model.pkl","rb"))

#define theano funtion to get output of FC layer
get_feature = theano.function([model.layers[0].input],model.layers[11].get_output(train=False),allow_input_downcast=False)
get_feature = theano.function([model.layers[0].input],model.layers[11].output,allow_input_downcast=False)

#define theano funtion to get output of first Conv layer
get_featuremap = theano.function([model.layers[0].input],model.layers[2].get_output(train=False),allow_input_downcast=False)
get_featuremap = theano.function([model.layers[0].input],model.layers[2].output,allow_input_downcast=False)


data, label = load_data()
Expand Down

0 comments on commit 44bf38d

Please sign in to comment.