2017-05-27 6 views
-1

私は奥行きのある畳み込みを適用しています。私は、4 x 4画像の最初の部分と2 x 2のフィルタにアクセスして、畳み込みが行われるようにしたいと考えています。誰かが私にそれをどうやってできるのか教えてもらえますか?テンソルフローの深さ方向畳み込みの結果を印刷するにはどうすればよいですか?

`input = tf.Variable(tf.random_normal([1,4,4,2])) 
filter= tf.Variable(tf.random_normal([2,2,2,1])) 
def depth_conv2d(input): 
    return tf.nn.depthwise_conv2d(input,filter, strides=[1,2,2,1],padding= 'SAME') 
depth_conv_out = depth_conv2d(input) 
sess = tf. InteractiveSession() 
sess.run(tf.initialize_all_variables()) 
print input.eval()[0][:3][:3]` 

答えて

0

問題

あなたは、画像の最初の「色」の4×4、およびその最初の「色」

ソリューション

import tensorflow as tf 

input = tf.Variable(tf.random_normal([1,4,4,2])) 
filter = tf.Variable(tf.random_normal([2,2,2,1])) 
def depth_conv2d(input): 
    return tf.nn.depthwise_conv2d(input,filter, strides=[1,2,2,1],padding= 'SAME') 
depth_conv_out = depth_conv2d(input) 
sess = tf.InteractiveSession() 
sess.run(tf.initialize_all_variables()) 

print "The first part of the 4x4 image" 
input_data = sess.run(input) 
print input_data[:,:,:,0] 
print "The first part of the 2x2 filter" 
filter_data = sess.run(filter) 
print filter_data[:,:,0,0] 

の検索結果をフィルタリングします2×2をしたいです

The first part of the 4x4 image 
[[[ 0.17095199 -0.24415942 -0.15299758 0.00659828] 
    [ 1.87758398 0.88201404 0.22255163 -0.52048266] 
    [-0.20067528 0.98255271 -2.09791732 -0.43816876] 
    [-0.37301171 0.6178537 2.05873895 1.97340238]]] 
The 2x2 filter 
[[-0.48764563 1.009269 ] 
[-0.82577544 0.75439191]] 
関連する問題