def discriminator(self,image, df_dim, reuse=True, name="discriminator"): with tf.variable_scope(name, reuse=tf.AUTO_REUSE): # image = [1,H,W,3] tf.get_variable_scope().reuse_variables() image = tf.expand_dims(image, 0) print(image.shape) h0 = lrelu(conv2d(image, self.df_dim, name='d_h0_conv')) print('tt',h0.shape) # h0 is [,H/2,W/2,self.df_dim] h1 = lrelu(pixel_norm(conv2d(h0, self.df_dim * 2, name='d_h1_conv'))) print(h1.shape) # h1 is [,H/4,W/4,self.df_dim*2] h2 = lrelu(pixel_norm(conv2d(h1, self.df_dim * 4, name='d_h2_conv'))) print(h2.shape) # h2 is [,H/8,W/8,self.df_dim*4] h3 = lrelu(pixel_norm(conv2d(h2, self.df_dim * 8, s=1, name='d_h3_conv'))) print(h3.shape) # h3 is [,H/8,W/8,self.df_dim*8] h4 = conv2d(h3, 1, s=1, name='d_h3_pred') print(h4.shape) # h4 is [,H/8,W/8,1] return h4
total_regions = [] total_asfmap = [] bbox = [(45, 90), (90, 45), (64, 64), (90, 180), (180, 90), (128, 128), (181, 362), (362, 181), (256, 256), (362, 724), (724, 362), (512, 512)] conv_height = 14 conv_width = 14 height = 600 width = 800 k = 12 gt_num = 10 feat_input = tf.placeholder(tf.float32, [None, conv_height, conv_width, 512]) with tf.variable_scope('rcnn', reuse=None): W_conv6 = weight_variable([3, 3, 512, 256], name="W_conv6") b_conv6 = bias_variable([256], name="b_conv6") feat = conv2d(feat_input, W_conv6) + b_conv6 W_offset = weight_variable([1, 1, 256, k * 4], name="W_offset") b_offset = bias_variable([k * 4], name="b_offset") offset = conv2d(feat, W_offset) + b_offset offset = tf.reshape(offset, [k * conv_height * conv_width, 4]) W_score = weight_variable([1, 1, 256, k], name="W_score") b_score = bias_variable([k], name="b_score") score = conv2d(feat, W_score) + b_score score = tf.reshape(score, [k * conv_height * conv_width]) config = tf.ConfigProto() config.gpu_options.allow_growth = True config.allow_soft_placement = True sess = tf.Session(config=config)
white_max): # 0.95这个参数请多调整,对应下面的0.05 end_ = m break return end_ #########################前向网络########################################## # define placeholder for inputs to network xs = tf.placeholder(tf.float32, [None, 28, 28, 1]) # 28x28 x_image = tf.reshape(xs, [-1, 28, 28, 1]) ## conv1 layer ## W_conv1 = func.weight_variable([5, 5, 1, 32]) # patch 5x5, in size 1, out size 32 b_conv1 = func.bias_variable([32]) h_conv1 = tf.nn.relu(func.conv2d(x_image, W_conv1) + b_conv1) # output size 28x28x32 h_pool1 = func.max_pool_2x2(h_conv1) # output size 14x14x32 ## conv2 layer ## W_conv2 = func.weight_variable([5, 5, 32, 64]) # patch 5x5, in size 32, out size 64 b_conv2 = func.bias_variable([64]) h_conv2 = tf.nn.relu(func.conv2d(h_pool1, W_conv2) + b_conv2) # output size 14x14x64 h_pool2 = func.max_pool_2x2(h_conv2) # output size 7x7x64 ## fc1 layer ## W_fc1 = func.weight_variable([7 * 7 * 64, 1024]) b_fc1 = func.bias_variable([1024]) # [n_samples, 7, 7, 64] ->> [n_samples, 7*7*64]