File tree Expand file tree Collapse file tree
DeepLearning Tutorials/dive_into_keras Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #coding=utf-8
2+
13"""
24Author:wepon
35Code:https://github.com/wepe
46
57File: get_feature_map.py
68 1. visualize feature map of Convolution Layer, Fully Connected layer
79 2. rewrite the code so you can treat CNN as feature extractor, see file: cnn-svm.py
10+
11+ --
12+ 2016.06.06更新:
13+ keras的API已经发生变化,现在可视化特征图可以直接调用接口,具体请参考:http://keras.io/visualization/
14+
15+
816"""
917from __future__ import print_function
1018import cPickle ,theano
1624model = cPickle .load (open ("model.pkl" ,"rb" ))
1725
1826#define theano funtion to get output of FC layer
19- get_feature = theano .function ([model .layers [0 ].input ],model .layers [11 ].get_output ( train = False ) ,allow_input_downcast = False )
27+ get_feature = theano .function ([model .layers [0 ].input ],model .layers [11 ].output ,allow_input_downcast = False )
2028
2129#define theano funtion to get output of first Conv layer
22- get_featuremap = theano .function ([model .layers [0 ].input ],model .layers [2 ].get_output ( train = False ) ,allow_input_downcast = False )
30+ get_featuremap = theano .function ([model .layers [0 ].input ],model .layers [2 ].output ,allow_input_downcast = False )
2331
2432
2533data , label = load_data ()
You can’t perform that action at this time.
0 commit comments