2016-03-02 41 views
9

पर सीखा फ़िल्टरों को विज़ुअलाइज़ करने के लिए कैसे करें कैफ़े फ्रेमवर्क के लिए, जहां सीएनएन प्रशिक्षण के दौरान सीखा फ़िल्टर देखना संभव है और इसके परिणामस्वरूप इनपुट छवियों के साथ रूपांतरण होता है, मुझे आश्चर्य है कि टेंसरफ्लो के साथ ऐसा करना संभव है या नहीं?tensorflow

एक Caffe उदाहरण के लिए इस लिंक में देखी जा सकती है:

http://nbviewer.jupyter.org/github/BVLC/caffe/blob/master/examples/00-classification.ipynb

आपकी मदद के लिए आभारी!

+0

यह भी देखें [tensorflow convolution फ़िल्टर कैसे देख सकते हैं?] (Http://stackoverflow.com/q/39361943/562769) –

+0

संभावित डुप्लिकेट [मैं टेंसफोर्लो में सीएनएन में वजन (चर) कैसे देख सकता हूं?] (http://stackoverflow.com/questions/33783672/how-can-i-visualize-the-weightsvariables-in-cnn-in-tensorflow) –

+0

आप [tensorflow डीबगर] का उपयोग कर सकते हैं (https://github.com/ ericjang/tdb) उपकरण – fabrizioM

उत्तर

10

Tensorboard में बस कुछ ही conv1 फिल्टर देखने के लिए, आप इस कोड का उपयोग कर सकते हैं (यह cifar10 लिए काम करता है)

# this should be a part of the inference(images) function in cifar10.py file 

# conv1 
with tf.variable_scope('conv1') as scope: 
    kernel = _variable_with_weight_decay('weights', shape=[5, 5, 3, 64], 
             stddev=1e-4, wd=0.0) 
    conv = tf.nn.conv2d(images, kernel, [1, 1, 1, 1], padding='SAME') 
    biases = _variable_on_cpu('biases', [64], tf.constant_initializer(0.0)) 
    bias = tf.nn.bias_add(conv, biases) 
    conv1 = tf.nn.relu(bias, name=scope.name) 
    _activation_summary(conv1) 

    with tf.variable_scope('visualization'): 
    # scale weights to [0 1], type is still float 
    x_min = tf.reduce_min(kernel) 
    x_max = tf.reduce_max(kernel) 
    kernel_0_to_1 = (kernel - x_min)/(x_max - x_min) 

    # to tf.image_summary format [batch_size, height, width, channels] 
    kernel_transposed = tf.transpose (kernel_0_to_1, [3, 0, 1, 2]) 

    # this will display random 3 filters from the 64 in conv1 
    tf.image_summary('conv1/filters', kernel_transposed, max_images=3) 

मैं भी एक ग्रिड में सभी 64 conv1 फिल्टर प्रदर्शित करने के लिए एक सरल gist लिखा था।

+0

क्या आप इस कोड का कोड सिफर 10 स्क्रिप्ट के "अनुमान" फ़ंक्शन के अंदर रखते हैं? – Twimnox

+0

मैंने नहीं किया, लेकिन यह एक अच्छा विचार है :) मैंने बस – etoropov

+0

वर्क्स के अनुसार कोड अपडेट किया है! धन्यवाद! मुझे "convert_image_dtype" के साथ कोई त्रुटि हो रही थी, इसलिए मैंने 'tf.image.convert_image_dtype (kernel_0_to_1, dtype = tf.uint8) '' kernel_0_to_255_uint8 = tf.cast (kernel_0_to_1, dtype = tf.float32)' को बदल दिया। – Twimnox