【发布时间】:2018-10-05 05:16:24
【问题描述】:
我想看看训练后过滤器采用了哪些值?如果在训练循环之后我提到 filter.eval() 它会得到过滤器在完成训练后采用的过滤器权重的值吗?我不认为我可以通过这种方式获得过滤器权重,因为过滤器变量调用了一个函数 weight_variable,该函数正在从正态分布中选择一些值。我认为在训练循环之后调用 filter.eval() 命令就像在训练之前打印过滤器一样。那么如何才能得到filter训练后采用的filter weights的值呢?
`def weight_variable(shape):
initial = tf.truncated_normal(shape, mean=0, stddev=0.1)
return tf.Variable(initial)
#network
x = tf.placeholder(tf.float32, [None,
FLAGS.image_height*FLAGS.image_width])
y_ = tf.placeholder(tf.float32, [None, 2])
input=tf.reshape(x,
[-1,FLAGS.image_height,FLAGS.image_width,FLAGS.input_channel])
filter = weight_variable([FLAGS.filter_size, FLAGS.filter_size,
FLAGS.input_channel, FLAGS.filter_channel])
conv_out = tf.nn.sigmoid(conv2d(input, filter))
pool_out = max_pool(conv_out)
pool_list = pool_out.get_shape().as_list()
input_dim = pool_list[1]* pool_list[2]* pool_list[3]
pool_2D = tf.reshape(pool_out, [-1, input_dim])
W_fc = weight_variable([input_dim, 2])
logits = tf.matmul(pool_2D, W_fc) #(batch_size,2)
y_conv=tf.nn.softmax(logits)`
检查正确的预测后应用训练循环
`
for i in range(max.training_step):
#Check training and test accuracy
print(filter.eval())`
【问题讨论】:
标签: python tensorflow