나는 tensorflow를 처음 사용하고 InteractiveSession에 문제가 있습니다. 다음 코드에서Tensorflow의 대화식 세션 - 컨볼 루션 연산자에 대한 다른 출력
: 나는 라인을 주석
import tensorflow as tf
def weight_variable(shape):
initial = tf.random_uniform(shape, 0, 10, seed=1, dtype="int32")
print("weights=\n",initial.eval())
return tf.Variable(tf.to_float(initial))
def conv2d(x, W):
return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME')
# first dimension: Number of examples to train on, 2nd and 3rd: example width and height,
# last one is: the number of channels
x = tf.to_float(tf.Variable([[[[1], [4], [5], [6], [7]],
[[10], [11], [22], [9], [8]],
[[24], [25], [20], [21], [19]],
[[14], [12], [13], [3], [18]],
[[15], [16], [19], [18], [17]]]])) # 1 example of 5x5 one channel image
sess = tf.InteractiveSession()
# The first two dimensions are the patch size, the next is the number of input channels,
# and the last is the number of output channels.
W_conv1 = weight_variable([2, 2, 1, 1]) #[3,3,3,64]
conv = conv2d(x, W_conv1)
sess.run(tf.initialize_all_variables())
print(sess.run(conv))
sess.close()
:
print("weights=\n",initial.eval())
내가 회선 print(sess.run(conv))
를 인쇄 할 때 내가 다른 결과를 얻을 수 있습니다. 키워드 eval이 세션과 상호 작용한다는 것을 이해합니다. 그러나 이해한다면, 사용 여부에 따라 출력이 변경되지 않습니다.
[[[[7]
[9]]
[[[3]
: 여기 는initial.eval()
사용시 얻는 출력[[2]]]] [[166.] [209.] [0127] [0126] 319.] [179.]],210
[386] [332] [314] [254] [181]
[293] [317] [262] [360] [171. I는 해당 광고를 언급 할 때]
[143] [168] [163] [154] [17]]]]
및 I 얻을 :
[150.] [173.] [148.] [73.]
[0123] [379] [379] [379] [379] [379] [379] [379] [379] [437] [437] [439] [437] [0126][283] [287] [211] [271] [177]
[249] [283] [295] [279] [119. ]]]]
156이 컨벌루션 출력의 나머지 95로 변경되었습니다.