def construct_up_block_2_sub_pixel(self, inputs, down_inputs, name, first=False, final=False): print("--------") print("Inputs:") print(inputs.shape) if first: # producing r^2 times more feature maps num_outputs = inputs.shape[self.channel_axis].value inputs = tf.contrib.layers.conv2d(inputs, num_outputs * self.conf.ratio**2, self.conv_size, scope=name + '/conv_sub_pixel', data_format='NHWC', activation_fn=None, biases_initializer=None) print("Conv before subpixel:") print(inputs.shape) sub_pixel_conv = self.deconv_func()( inputs=inputs, scope=name + '/subpixel', r=self.conf.ratio, debug=self.conf.debug, activation=self.conf.activation_function) print("Sub Pixel:") print(sub_pixel_conv.shape) concat = tf.concat([sub_pixel_conv, down_inputs], self.channel_axis, name=name + '/concat') print("Sub Pixel + down inputs:") print(concat.shape) num_outputs = concat.shape[self.channel_axis].value num_outputs = num_outputs / 2 if final else num_outputs conv2 = ops.conv2d(concat, num_outputs, self.conv_size, name + '/conv2', activation=self.conf.activation_function) print("Conv after concat:") print(conv2.shape) num_outputs = self.conf.class_num if final else num_outputs conv3 = ops.conv2d(conv2, num_outputs, self.conv_size, name + '/conv3', activation=self.conf.activation_function) print("Conv:") print(conv3.shape) return conv3
def construct_up_block(self, inputs, down_inputs, name, final=False): num_outputs = inputs.shape[self.channel_axis].value conv1 = self.deconv_func()(inputs, num_outputs, self.conv_size, name + '/conv1') print("--------") print("Inputs:") print(inputs.shape) print("Deconv:") print(conv1.shape) print("Down inputs:") print(down_inputs.shape) conv1 = tf.concat([conv1, down_inputs], self.channel_axis, name=name + '/concat') print("After concat:") print(conv1.shape) conv2 = self.conv_func()(conv1, num_outputs, self.conv_size, name + '/conv2') num_outputs = self.conf.class_num if final else num_outputs / 2 print("Conv2:") print(conv2.shape) conv3 = ops.conv2d(conv2, num_outputs, self.conv_size, name + '/conv3') print("Conv3:") print(conv3.shape) print("--------") return conv3
def construct_down_block(self, inputs, name, down_outputs, first=False): num_outputs = self.conf.start_channel_num if first else 2 * inputs.shape[ self.channel_axis].value conv1 = ops.conv2d(inputs, num_outputs, self.conv_size, name + '/conv1', activation=self.conf.activation_function) conv2 = ops.conv2d(conv1, num_outputs, self.conv_size, name + '/conv2', activation=self.conf.activation_function) down_outputs.append(conv2) pool = ops.pool2d(conv2, self.pool_size, name + '/pool') return pool
def construct_bottom_block(self, inputs, name): print("--------") print("Bottom layer:") print("Inputs:") print(inputs.shape) num_outputs = inputs.shape[self.channel_axis].value conv1 = ops.conv2d(inputs, 2 * num_outputs, self.conv_size, name + '/conv1', activation=self.conf.activation_function) print("Conv1:") print(conv1.shape) if self.conf.up_architecture == 1 or self.conf.up_architecture == 2: conv2 = ops.conv2d(conv1, num_outputs, self.conv_size, name + '/conv2', activation=self.conf.activation_function) print("Conv2:") print(conv2.shape) return conv2 else: return conv1
def construct_up_block_5_sub_pixel(self, inputs, down_inputs, name, first=False, final=False): print("--------") print("Inputs:") print(inputs.shape) if first: # producing r^2 times more feature maps (in this architecture the first layer only # needs to produce 2x more feature maps) num_outputs = inputs.shape[self.channel_axis].value inputs = tf.contrib.layers.conv2d(inputs, num_outputs * 2, self.conv_size, scope=name + '/conv_sub_pixel', data_format='NHWC', activation_fn=None, biases_initializer=None) print("Conv before subpixel:") print(inputs.shape) sub_pixel_conv = self.deconv_func()( inputs=inputs, scope=name + '/subpixel', r=self.conf.ratio, debug=self.conf.debug, activation=self.conf.activation_function) print("Sub Pixel:") print(sub_pixel_conv.shape) outputs = tf.concat([sub_pixel_conv, down_inputs], self.channel_axis, name=name + '/concat') print("Sub Pixel + down inputs:") print(outputs.shape) num_outputs = outputs.shape[self.channel_axis].value if final: outputs = ops.conv2d(outputs, num_outputs, self.conv_size, name + '/unique_conv', activation=self.conf.activation_function) print("Conv unique:") print(outputs.shape) num_outputs = num_outputs / 2 if final else num_outputs outputs = ops.conv2d(outputs, num_outputs, self.conv_size, name + '/conv2', activation=self.conf.activation_function) print("Conv after concat:") print(outputs.shape) if final: print("Its the final one:") num_outputs = self.conf.class_num outputs = tf.contrib.layers.conv2d(outputs, num_outputs, kernel_size=(1, 1), stride=1, scope=name + '/conv_final', data_format='NHWC', activation_fn=None, biases_initializer=None, padding='VALID') else: outputs = ops.conv2d(outputs, num_outputs, self.conv_size, name + '/conv3', activation=self.conf.activation_function) print("Conv:") print(outputs.shape) return outputs